Robert,
I take your point and agree that such independence of the base type from derived types would be ideal.
However this pure approach falls down (IMHO) if it leads you to have a lot of properties and methods in the base type that do not apply in some or even most of the derived types.
So a competing ideal is that a type only contain or provide those properties and methods that make sense for it.
When I want a derived type that introduces a new method say, I don't want to go back through the hierarchy adding it all the way back to the base - abstract or not. And when it is abstract, doesn't each derived type that isn't abstract have to provide an implementation ?
So I'm finding that somewhere between the two ideals is what works in practice.
I'm still learning about this object stuff so I'm happy to hear a different point of view.
I'm working on one project in BlitzMax where there is a deep object hierarchy. Each type in the hierarchy maintains a TList so when I need to apply a method that exists only in a type and its derivatives then I iterate through the appropriate list. I don't iterate through the top level list and check the type before invoking the method if it is appropriate.
It is a bit lengthy to show here but when it is done I plan to submit it for comment. Perhaps somebody could come up with a better design.
PGF
I take your point and agree that such independence of the base type from derived types would be ideal.
However this pure approach falls down (IMHO) if it leads you to have a lot of properties and methods in the base type that do not apply in some or even most of the derived types.
So a competing ideal is that a type only contain or provide those properties and methods that make sense for it.
When I want a derived type that introduces a new method say, I don't want to go back through the hierarchy adding it all the way back to the base - abstract or not. And when it is abstract, doesn't each derived type that isn't abstract have to provide an implementation ?
So I'm finding that somewhere between the two ideals is what works in practice.
I'm still learning about this object stuff so I'm happy to hear a different point of view.
I'm working on one project in BlitzMax where there is a deep object hierarchy. Each type in the hierarchy maintains a TList so when I need to apply a method that exists only in a type and its derivatives then I iterate through the appropriate list. I don't iterate through the top level list and check the type before invoking the method if it is appropriate.
It is a bit lengthy to show here but when it is done I plan to submit it for comment. Perhaps somebody could come up with a better design.
PGF