Design advice needed
Hi everyone,
I need some help with a design problem that I have. I am not exactly a software developer by profession, so I am hoping to get some suggestion from the experts here.
Well, basically I have 2 types of tracking systems (optical and sonar). So, basically I have an interface object and they both should inherit from it.
Howeever, my problem is that they both take different parameters for initialization. So, if I have a method calloed Initialize, I cannot share it between then as they take different parameters for initializazion.
I was wondering what kind of design patterns you guys would recommend for developing objects that are of course same from a functional point of you, but differ internally quite substantially.
Thanks and cheers,
xargon
[809 byte] By [
xargon] at [2007-11-19 14:51:28]

# 1 Re: Design advice needed
first check if they really should inherit from the same object by reading this through to the end: http://www.parashift.com/c++-faq-lite/proper-inheritance.html#faq-21.6
The most important part being
objects of the derived class must behave in a manner consistent with the promises made in the base class' contract.
If you're still sure you should be inheriting from the same interface then I'll need to be less drunk to answer properly.
Oh man how sad am I replying the CG posts when drunk
# 2 Re: Design advice needed
Sounds like your inheretance is ok, they are both interface objects and should function in a similar fashion thus the inheretance. I imagine there is a good reason you can't use the constructor to initialise the objects so lets look at how you can override the initialise method to provide some more functionality.
I assume you're programming in C++, so if your defining the function Initialise in the base class and providing all the common initialisation functions then you should be fine. Just create new overloaded functions for your two sub classes called Initialise with the relevant parameters and call the superclass' Initialise from within the function.