4 ms·
Whenever I’ve worked, I was always advocating to use subclassing as a last resort solution. It’s the most intimate and brittle relationship you can have between
by tzahola 8y ago
Whenever I’ve worked, I was always advocating to use subclassing as a last resort solution. It’s the most intimate and brittle relationship you can have between your classes.
Unfortunately the majority of OOP books don’t emphasize this, so beginners try to do everything by subclassing, as if that was what OOP is about...
- scarface74 8y agoI've hardly ever found a good reason to inherit functionality - plain old data objects yes, but I always favor aggregation over inheritance. When it comes to inheriting a base object to reuse cross cutting concerns, not only do you run into the fragile base class problem - there is usually a better way. I personally prefer aspect oriented programming when possible.
- psyc 8y agoI cannot recall an instance where virtual methods were definitely my best option. I have used them sparingly, but I suspect further review would reveal a perfectly good alternative. I have always considered them one of the least readable constructs.