Design issue with constructor arguments
- From: "Caroline M" <caroline@xxxxxxxxxxxxxx>
- Date: 7 Dec 2006 04:23:20 -0800
Hi all,
I'm writing a C++ program and I've come across a design issue that I
seem to keep getting but I dont know if it has a name or something.
I am writing a library which is to be used by some client code. In this
library I have a single front end class which acts as a kind of facade
into the library. Clients can instantiate one of these to gain the use
of the library. Internally, I have many classes and one of these is a
special processing class which invokes callback function supplied by
the client.
Thus this processing class has functions to allow the client to
register and unregister callback functions but they dont get to use
this class directly - those functions are mirrored on my front end
class. So the idea is that the front end class instantiates the
processor and fowards requests to register callbacks. All good so far.
The problem that I am experiencing is that internally, the classes that
need to use this processor are buried way down in the internals of the
library. There are something like five classes in between the front end
and the one that actually needs a reference to this processor.
Currently, I instantiate the processor and then pass a reference to it
via constructor calls. This pattern is repeated through these five
classes - each passing the reference down to the next class. But these
classes in the middle really shouldn't have any knowledge of the
processor.
It would be a lot easier to describe this with a simple diagram so I
hope I have made sense! Basically, I want class A, to create an
instance of class B and give it to class X, without having to give it
to class C who gives it to D who gives it to E etc etc and finally it
gets to X.
Any ideas?
Caroline Middlebrook
.
- Follow-Ups:
- Re: Design issue with constructor arguments
- From: H. S. Lahman
- Re: Design issue with constructor arguments
- From: Mark Nicholls
- Re: Design issue with constructor arguments
- Prev by Date: Re: confusion about data abstraction
- Next by Date: Re: Design issue with constructor arguments
- Previous by thread: confusion about data abstraction
- Next by thread: Re: Design issue with constructor arguments
- Index(es):
Relevant Pages
|