Hacker News new | past | comments | ask | show | jobs | submit login

OLOO is quite different from both inheritance and composition. It embraces delegation rather than covering it up or running away from it. :)



Can 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.


A 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

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%...


Ah, thanks. That clarifies things. Neat!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: