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.
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.
Layoffs
Yesterday
10545
Google CFO confirms "large-scale" layoffs today (Apr 17)
2024 Presidential Election
Yesterday
1583
If you vote for Biden this year, don't complain about layoffs
Tech Industry
Yesterday
1834
What is the appeal to NVIDIA?
Tech Industry
Yesterday
10621
Goog Employees Arrested
Tech Industry
Yesterday
402
Are you excited about going to work every morning?
The answer to any sort of question like this is “it depends”. There are rarely any one-size-fits-all solutions