Let’s say that I have class, that uses some functionality of dict. I used to composite a dict object inside and provide some access from the outside, but recently thought about simply inheriting dict and adding some attributes and methods that I might require. Is it a good way to go, or should I stick to composition?
Let’s say that I have class , that uses some functionality of dict .
Share
Inheritance is very often abused. Unless your class is meant to be used as a generic dictionary with extra functionality, I would say composition is the way to go.
Saving forwarding calls is usually not a good enough reason for choosing inheritance.
From the Design Pattern book:
The entire text is here:
http://blog.platinumsolutions.com/node/129