Friday, February 4, 2011

Poor Design – Excessive inheritance

Very often while developing the object oriented systems we have the base master class which has most of the common functionalities like a super dad who can do everything and all its offsprings (child classes) inherit this functionality.

But sometimes just like in real world as the offspring specialize and differentiate themselves from the super dad and develop there own personality there are situation wherein a derived offspring shouldn’t have the functionality but still has the functionality.

I believe a good object oriented system is always closer to the real world and this is where I favor composition over inheritance, a system where each offspring develop there distinct personality by attaining different skills basically the offspring inherit the common features but attain the different skills(functionalites) by composition.

No comments:

Post a Comment