News for hackers. Stuff that matters.
Re:Inheritance Is Terrible by ChuckMcM on Saturday March 19, 2016 @04:56PM (#11320415)
So when I read this, "Later, however, the business needs to start tracking the royalty paid to the author of a book separately from the rest of the price." I felt the author is conflating "inheritance" with "requirements".

I don't think anyone would argue that if you design system, and then change the requirements of what the system should do. You have two choices; build a new system that meets both the old and new requirements or patch the old system to kind of meet the new requirements.

And I get that this critique is looking at the example perhaps more literally than the message, which is that it is hard to make systemic changes to object oriented systems, but that criticism of OOP is well trodden. Bjarne and others will tell you that it is easy to make reliable and testable additions to an OO system and that is its strength. Refactoring such systems in the face of new requirements will always be hard, and yet the argument goes that if you do so correctly you will be able to re-use tests from the previous system to verify it still works the way it did and write new tests to show that it works the new way as well.

The example of books and movies is a good one because shows how initially the thinking that every item has a price, but what should have been considered is that some items are of a type 'media' that has other attributes that regular items don't. If you are familiar with the joke[1], it is the dichotomy between a toaster and a "cooker of breakfast foods".

[1] http://www.danielsen.com/jokes/objecttoaster.txt

There are no comments on this comment yet.