r/programming • • Sep 24 '15

Composition over Inheritance

https://medium.com/humans-create-software/composition-over-inheritance-cb6f88070205
92 Upvotes

48 comments sorted by

View all comments

2

u/logged_in_for_this Sep 24 '15

So when using a composition, objects have state and agents that act upon that state?

5

u/[deleted] Sep 24 '15 edited Sep 24 '15

So when using a composition, objects have state and agents that act upon that state?

This is not a concept in composition. In composition, every object has its own state, and objects communicate with each other only through their intended public API.

What the author of that video is demonstrating is mix-ins, and "state.foo" stands for "this.foo", because the code examples are avoiding using "this" for some reason.