Design question.... parent/child class

Gumuz gumuz at
Tue Sep 3 11:15:42 EDT 2002

I'm sorry, I don't think I understand it correctly.

Do you mean i should create a third Interface class just to communicate to
the other class? Isn't that then just the same but with an extra class?

"Peter Hansen" <peter at> wrote in message
news:3d74b283$1 at
> Gumuz wrote:
> > hi all,
> >
> > i have a SessionManager class, which contains a list of Session
> > objects(instantiated from a Session class). I have a design problem.
> >
> > Each session object has a small 'queue' of messages for the specific
> > session. How can a session send a message to another session without
> > some kind of parent-reference to the SessionManager object?
> >
> > i am a bit puzzled, or is this parent-reference not such a bad idea
> > all?
> Increasing coupling is always bad, but you could do this in a way that
> doesn't really increase coupling (at least in Python).  The Session
> objects don't need to know about SessionManagers specifically, just
> about some thing that has a particular interface.  In this case, maybe
> it's a "post" method.  Pass in a reference to the SessionManager,
> or even the post method itself (a "bound" method, bound to a specific
> SessionManager instance), but don't do an "import sessionmanager"
> or anything like that in the module itself.
> Note that passing messages between Sessions could be considered a
> function not appropriate for something called merely "SessionManager".
> Maybe you want to do this with another mechanism in parallel to this,
> or rename that class.  Personally, I wouldn't do that unless the
> whole design was starting to get complex.
> -Peter

More information about the Python-list mailing list