6 ms·
OLOO is quite different from both inheritance and composition. It embraces delegation rather than covering it up or running away from it. :)
by _getify 13y ago
OLOO is quite different from both inheritance and composition. It embraces delegation rather than covering it up or running away from it. :)
- jkrems 13y agoCan you give an actual example of the difference between composition and delegation? In my definition those two are just two different perspectives on the same thing.
- _getify 13y agoA super quick, simple illustration of the difference, which comes down to the fact that delegation is differential, whereas composition is complete: https://gist.github.com/getify/9895188 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%20&%20object%20prototypes/ch6.md#simpler-design https://github.com/getify/You-Dont-Know-JS/blob/master/this%...
- jkrems 13y agoAh, thanks. That clarifies things. Neat!