We do not want the duplicate code lying around in all of your sub components. So the common stuff that require to connect to the database/rendering the output/etc.. can be pushed up the chain to MikeBaseComponent.
Ok. Let me rephrase it in "OO" terminology.
+ The Children inherit the characteristics of the Parent -i.e. Parent passes on its characteristics to the Children. Now, how do we program this concept in our chosen language?
Take your example:
abstract class Shape
{
abstract double getArea();
}
class Square
{
double getArea()
{
return ...;
}
}
class Circle
{
double getArea()
{
return ...;
}
}
class Rectangle
{
doubl getArea()
{
return ...;
}
}
and so on. For every child of Shape there will be some specific implementation of getArea().
Now, what we have here in the Parent class Shape is, a characteristic called area. Parent says to anyone who cares about it, "look, I have a characteristic called area. I know for sure my children will have this characteristic, but at this moment in time, I am not sure how that characteristic is going to be mutated by the time my child is born. So, I am going to leave it for them to sort it out."
Now, child is about to be born. It looks up and sees, hmm... Parent is saying to sort myself out. Ok. I sort myself out before I go out to the world.
This is the rationale behind the
MikeBaseComponent represents the common characteristics of its sub classes and it maintains the "IS-A" semantic with the AcmeFramework's Component class. So you can see the direction is still one way.
If all you want is to use "querying the database" functionality, there is no need to extend, you can simple call this class’ methods.
If you notice, I mentioned that this is a specific example of numerous other occurrences where abstract/concrete can be useful to the design of a solution.
IMHO, this arrangement is a benefit to the overall design of a business solution. If we can map all the business requirements to the classic Shape/Circle/Square example (OO's version helloworld example), the mega buck earners with the tag 'architects' would be queuing infront of unemployment benefit offices.
Thanks for the recommendation of Joshua's book.