[MUD-Dev] OO Design Question

Brad Leach c9608122 at alinga.newcastle.edu.au
Wed Nov 11 11:24:05 New Zealand Daylight Time 1998


Greetings,

	I have a question for the OO designers out there. :-)

Background:

	My server is written in C++ and I am trying to design/code it with some
basic OO principles (I haven't had any formal OO training, but I do own
Design Patterns (GoF)).

	The server is to be designed as a multi-purpose server. Basically I would
like to have a standard server class that has other specific servers derived
from this (e.g. AServer is the base for MudServer, TelnetServer, WebServer,
etc) [Note: I havent evaluated if this is feasable yet - its just a wild
idea in relation to reuse].


My question is this:  Should the "Server" object be started (via a public
"startup" function) and look after everything (Method "A") or should the
main() function look after the specific's of calling AServer::Init(),
AServer::MainLoop(), etc (Method "B").

For instance, in method A, the code would be something like:
int main( /* args */ )
{
	AServer * server;

	server = new AServer( /* args */ );
	server.Startup( /* args */ );
}

In method B, the code would be something like:
int main( /* args */ )
{
	AServer * server;

	server = new AServer( /* args */ );
	server.Init();

	while ( server.IsUp() )
	{
		server.CheckNewConn();
		server.Input();
		server.UpdateEvents();
		server.Output();
		server.UpdateTime();
	}
	server.cleanup();
}

I hope that explains the question. It is quite difficult to express my
thoughts in words at the moment. :-)

Thanks in advance,
-Brad





More information about the MUD-Dev mailing list