Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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: