in reply to Bundling unrelated classes

A design in which every object needs to be able to call methods on every other kind of object seems messy.

A typical approach is to adopt a layered architecture, where the lower-level objects don't know much about the higher-level ones.

For example, perhaps instead of having references to all of the other objects, the connection object can get by with just converting the incoming message into a standard format and passing it to a callback function? That way, some object from a higher layer could create the connection, pass it the relevant configuration information, and register the callback to be invoked when a message is received.

Replies are listed 'Best First'.
Re^2: Bundling unrelated classes
by redlemon (Hermit) on Dec 18, 2004 at 20:45 UTC

    It's not that I'm injecting all methods from all objects into each others namespaces, just that every object carries a reference to it's 'siblings' and 'parent'.

    But your suggestion of using my own callbacks is one I'll explore. thanks.