[Home] [Groups] - Message: [Prev in Group] [Next in Group]
8964: [MUD-Dev] OO Design Question
[Full Header] [Plain Text]
From: "Brad Leach" <c9608122@alinga.newcastle.edu.au>
Newsgroups: nu.kanga.list.mud-dev
Date: Wed, 11 Nov 1998 11:24:05 +1100
Organization: Kanga.Nu
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