Please help me settle an argument that has been simmering for almost a week now at my workplace. I'm having a hard time convincing one of our product designers that there is a really basic design smell in our new product, so I thought I would throw this question out to the gurus and code Jedis populating these forums.
So the overview:
We have 2 singleton classes - an overall Application class and a MessageRouter class. The routing mechanism is accomplished through the use of Agent classes, this class is a base class from which we subclass multiple concrete Agent types. Agent objects must register with the router in order to be notified of state changes. Also, agent registration with the router will occur in multiple places inside the code - not just within Application.
On program startup, the original proposed architecture was as follows:
Proposal A:
Code:
Code:
Application::Initialize()
{
AgentSubclass foo = new AgentSublass()
foo->Initialize()
}
Agent::Initialize()
{
MessageRouter::Instance()->Register(this)
}
Proposal B:
Code:
Code:
Application::Initialize()
{
AgentSubclass foo = new AgentSublass()
foo->Initialize(MessageRouter::Instance())
}
Agent::Initialize(MessageRouter *pRt)
{
pRt->Register(this)
}
Thanks for the help.

