S
Scott
Hi,
I'm designing an API of container objects such that:
there is an abstract ContainerObject,
ContainerObjectA extends ContainerObject, and stores:
ContainerObjectB, which extends ContainerObject, and stores:
ContainerObjectC, which extends ContainerObject, and stores:
ContainerObjectD, which also extends ContainerObject.
However, I wish to make ContainerObjectD an abstract class that must be
extended by the API user to allow for customization of the final level of
containment. This may seem a little odd, but the data is organized in
such a way that the upper levels of containment objects will be identical,
but the lower objects will differ (i.e. ContainerObjectD will contain
one or more customizable objects). So, my question is, how do I handle
ContainerObjectC? - it will only ever access the interfaces in
ContainerObjectD defined by the abstract ContainerObject, not any of the
extended elements. But, I won't know what the name or location of the
extended object of ContainerObjectD will be. Do I just leave it to the
API user to edit ContainerObjectC and insert the name of the new extended
class, or is there a way to approach this is a more structured manner?
Also, can an abstract class be extended by an abstract class? Should I
use an interface instead? That will still leave the problem of how I
should refer to the abstract class within a non-abstract one. I hope this
makes sense, and thanks for any advice!
Best Regards,
Scott
I'm designing an API of container objects such that:
there is an abstract ContainerObject,
ContainerObjectA extends ContainerObject, and stores:
ContainerObjectB, which extends ContainerObject, and stores:
ContainerObjectC, which extends ContainerObject, and stores:
ContainerObjectD, which also extends ContainerObject.
However, I wish to make ContainerObjectD an abstract class that must be
extended by the API user to allow for customization of the final level of
containment. This may seem a little odd, but the data is organized in
such a way that the upper levels of containment objects will be identical,
but the lower objects will differ (i.e. ContainerObjectD will contain
one or more customizable objects). So, my question is, how do I handle
ContainerObjectC? - it will only ever access the interfaces in
ContainerObjectD defined by the abstract ContainerObject, not any of the
extended elements. But, I won't know what the name or location of the
extended object of ContainerObjectD will be. Do I just leave it to the
API user to edit ContainerObjectC and insert the name of the new extended
class, or is there a way to approach this is a more structured manner?
Also, can an abstract class be extended by an abstract class? Should I
use an interface instead? That will still leave the problem of how I
should refer to the abstract class within a non-abstract one. I hope this
makes sense, and thanks for any advice!
Best Regards,
Scott