Re: C++ framework design question
Angus wrote:
I am creating a C++ framework for working with telephone systems.
There are a lot of different interfaces and this is the main problem.
Currently my basic design is as follows:
Abstract factory pattern. Creates a telephony object without
specifying concrete classes.
The telephony object then creates a interface class (IFace) which has
supporting device and call classes. The IFACE class has a list of the
calls and devices. Devices are for example a telephone handset.
The IFace, device and call objects are abstract. Then I have these
sort of interfaces for actual implementation:
class ABCPhone: public IFace
class ABCDevice : public device
class ABCCall : public call
Currently I am working on two actual implementations - lets call them
ABC and XYX.
When I created the ABC implementation I would create for example ABC
devices and calls and put a lot of the device and call processing code
in IFace, device and call. This has the advantage that anything in
the abstract classes can be re-used. But the problem is that now I am
developing XYZ interface, the standard code in these abstract classes
needs to be extended to cope with the peculiarities of XYZ.
Unfortunately XYZ is quite different to ABC.
So I am re-writing a lot of the code originally in IFace, device and
call into ABCPhone, ABCDevice and ABCCall. That is fine but means I
will have quite a lot of specific code for each implementation (longer
development cycles).
For example, is it a good idea to have a list of eg call objects in
the IFace class? If I need to extend call for specific
implementations then I need a list of XYZCalls for example? Then no
need for a list of call's?
Any tips on how to design this would be much appreciated.
These are great questions. I don't have time to answer them now,
sorry. I would, however, like to recommend two other newsgroups
since they seem fitting your problem. One is 'comp.object'.
Certain principles (interface, implementation, commonailities vs
specifics) are not limited to C++ and you can find lots of help
from the kind folk in 'comp.object'. The other newsgroup is
'comp.software-eng' since you mentioned design for reuse and
maintainability. There are some engineering principles you can
apply to your work that aren't C++ specific either.
I am sure somebody will address your C++ concerns, just don't
discount the other opportunities, they can be even more useful
if you abstract from the particularities of the chosen language.
Good luck!
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask