Inheritance usage question
I have 2 classes, DBContainerGraphic and DBGraphic. The DBGraphic class has a static method called Create() which creates and returns a DBGraphic object. The DBContainerGraphic extends DBGraphic. DBContainerGraphic also uses a static factory method.
Now, DBContainerGraphic is inheriting the static method from DBGraphic that instantiates and returns a DBGraphic. [note: it does have a different signature] This create method does not make sense in the context of DBContainerGraphic.
It will work, but it is not returning a DBContainerGraphic, and thus I feel it should not be exposed on the DBContainerGraphic class.
What should I do about this? Just ignore it? After all, it is only package scope.
[724 byte] By [
_dnoyeBa] at [2007-9-30 0:12:05]

class DBGraphic
{
static DBGraphic makeGraphic() { return new DBGraphic(); }
}
class DBContainerGraphic
extends DBGraphic
{
static DBContainerGraphic makeContainerGraphic() { return new DBContainerGraphic(); }
static DBGraphic makeGraphic() { return new DBContainerGraphic(); }
}
That is almost certainly NOT what you should do though. Instead of refactoring the whole set of classes, in effect introducing some zillion possible bugs, just use the existing classes and then change them slowly over time.
The advantage of using the existing classes, is that you are finished the project as soon as you start, like right away.
Andrew
hehe, yea thats how I like to do it. Just get it done, then refactor.That hiding gives me some comfort. I will do this if opportunity arrises. Currently I realized that I should just encapsulate the class instead of extend it.