Always / sometimes / never?
Rarely are there 100% certainties in best practices. They’re largely true, but we shouldn’t get lost in them if they somehow lower the bar for the quality of the codebase.
But the problem is that everyone thinks they have the exception to the rule.
If my colleagues want to forego norms, I ask for reasons, and they must be particularly compelling.
I would take a good inheritance all day. Otoh , I suck at music so no compositions happening anytime soon.
Mostly. Way easier to unit test.
In C++, public inheritance should only be used when you want to establish an "is-a" relationship (substitutability). It's a very strong relationship. In all other cases you should use composition to import desired functionality. (In some cases, private inheritance can be used for composition.)
Composition is a “has a” relationship and inheritance is a “is a” relationship. Here’s an easy way to figure out whether you should use one or the other. If I inherit the class will I be writing less code ? Inheritance saves you variable duplication because lone and behold... the parent contains those variables. If I want to extend a function and be able to decorate the parent function. Composition would it make sense to compose this object and use it else where ? To reduce coding more ? These key points are how you basically write oop code.
Software Engineering Career
Yesterday
1419
Cleared Amazon onsite, but lowballed.
Tech Industry
Yesterday
978
Update: Trans Coworker Stealing Breast Milk
Tech Industry
Yesterday
3056
The job market is absolutely brutal right now
Tech Industry
Yesterday
624
Modi is the worst dictator!
Tech Industry
Yesterday
519
Do you prefer shorter women or taller women
The answer to any sort of question like this is “it depends”. There are rarely any one-size-fits-all solutions