News for hackers. Stuff that matters.
Re:Inheritance Is Terrible by wvenable on Saturday March 19, 2016 @10:58PM (#11321592)
But that's not true as it's not a binary choice. The idea of adding a Perishable interface works just as well whether or not items extend a single base class.

Sometimes cluttering the base class is a better solution if there is a meaningful default. For example, if you start with all non-taxable items and the requirements change for taxable items -- it makes sense to implement in the base class as a Tax property that defaults to zero. Then you don't need conditionals and interface checks whenever you want to display or do tax calculations.

There are no comments on this comment yet.