I can't support composition >> inheritance enough. From my experience it's such a classic error in OO programming, as junior and even intermediate devs keep thinking that inheritance is the default way to add reusability and encapsulation. And the worst part is I remember when I thought the same!
Especially as I've moved to a more TDD and CI approach I've found this principle to be one of the most important to writing quality, maintainable code.
Thanks for writing this, and I hope others can learn from it now instead of waiting for their own mistakes...
Thanks a lot for your input Simon! I think of this principle as the common case where something used to be an acceptable solution, but since then evolved into a bad design practice...
With composition you get rid of the "hidden magic" inheritance provides, and oh, does it make life better!
Perhaps I'll write a post exclusively about this principle sometime soon...
Thanks again for sharing!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I can't support composition >> inheritance enough. From my experience it's such a classic error in OO programming, as junior and even intermediate devs keep thinking that inheritance is the default way to add reusability and encapsulation. And the worst part is I remember when I thought the same!
Especially as I've moved to a more TDD and CI approach I've found this principle to be one of the most important to writing quality, maintainable code.
Thanks for writing this, and I hope others can learn from it now instead of waiting for their own mistakes...
Thanks a lot for your input Simon! I think of this principle as the common case where something used to be an acceptable solution, but since then evolved into a bad design practice...
With composition you get rid of the "hidden magic" inheritance provides, and oh, does it make life better!
Perhaps I'll write a post exclusively about this principle sometime soon...
Thanks again for sharing!