by _getify · 12y ago · 0 comments
I have been writing about exactly this topic, of why classes don't make sense (specifically for JS), in my second title of the "You Don't Know JS" book series, "this & Object Prototypes".
In particular, Chapter 6 makes the case for an alternate pattern to class-orientation design, which I call OLOO (objects-linked-to-other-objects) style code. OLOO implements the "behavior delegation" design pattern, and embraces simply peer objects linked together, instead of the awkwardness of parent-child abstract class semantics.
https://github.com/getify/You-Dont-Know-JS/blob/master/this%...
https://github.com/getify/You-Dont-Know-JS/tree/master/this%...
Or does it mean something else?
https://gist.github.com/getify/9895188
For a bit more "real world" of a scenario, you can also compare the `LoginController` / `AuthController` mechanism here, first shown with inheritance+composition, and then shown with simpler OLOO-style delegation:
https://github.com/getify/You-Dont-Know-JS/blob/master/this%...