I am not alone in my suspicion of inheritance. Sutter says with good reason to "Always prefer composition over inheritance". Stroustrup views base classes as "Places to put commonality".
Monday, January 02, 2006
Anti-Pattern of the day - Inheritance == object oriented development
Object oriented programming is about the objects themselves, not about whether they are part of an inheritance hierarchy. How many times have I encountered an inheritance hierarchy where the "objects" that make it up have no copy constructor or assignment operator and are not disposed of correctly. Common symptoms of this particular anti-pattern are memory leaks and it's bedfellow, confusion of ownership.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment