4 ms·
Sandi Metz does a far better job explaining the proper use of OOP in this video: [0] I highly encourage anyone with doubts about OOP to actually complete that
by voodootrucker 7y ago
Sandi Metz does a far better job explaining the proper use of OOP in this video: [0]
I highly encourage anyone with doubts about OOP to actually complete that Kata.
In short, inheritance should be confined to removing conditionals in problems with shallow-wide [1] inheritance graphs, where things truly "is-a" thing, not "have-a" thing [2]
Real life examples I've encountered:
* buttons in a toolbar implementing a command interface
* database drivers extending a base implementation
* web-server endpoints extending a base implementation
Some of the most complex software in the world is currently modeled using OOP. If one is ever in doubt, look into creating plugins for IntelliJ. The whole program is a massive exercise in OOP modelling, and it works pretty well (if not a little slow some times) [3]
[0] https://www.youtube.com/watch?v=8bZh5LMaSmE https://www.youtube.com/watch?v=8bZh5LMaSmE
[1] http://cek.io/blog/2014/05/26/poodr-ch-7/ http://cek.io/blog/2014/05/26/poodr-ch-7/
[2] https://stackoverflow.com/questions/2218937/has-a-is-a-terminology-in-object-oriented-language https://stackoverflow.com/questions/2218937/has-a-is-a-termi...
[3] https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started.html https://www.jetbrains.org/intellij/sdk/docs/basics/getting_s...