3 ms·
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.
by wvenable 11y ago
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.