You can think about how ICS-V6 components are implemented. They all derive
(inherit) from the same base class (TIcsWndControl). This class is a generic
class. Then every component use (by delegation) one or more TWSocket to
implement the specific protocol with properties, methods and events specific
to each protocol.
--
[EMAIL PROTECTED]
The author of the freeware multi-tier middleware MidWare
The author of the freeware Internet Component Suite (ICS)
http://www.overbyte.be
- Original Message -
From: Jack [EMAIL PROTECTED]
To: ICS support mailing twsocket@elists.org
Sent: Monday, May 28, 2007 6:58 AM
Subject: [twsocket] Seeking OO design suggestions
I'm planning on implementing a set of test classes to test multiple
servers
speaking various protocols (for example: HTTP, SMTP, and proprietary
protocols.) There are multiple servers of each type. I use some very
simple
protocol-aware packets to check if the ports are open and if the servers
are functional. For each type of server, I use multiple (say, 10) async
sockets to connect to the servers to speed up testing.
I'm thinking about two different ways of implement it, both trying to
share as much code as possible.
Design 1. Have socket classes derived from TWSocket, implement the
protocol
specific logic in those class, and share a common master class to create
multiple socket instances for each protocol. The master class
(TServerTester) creates different tester sockets based on an argument
in the constructor.
Socket classes have the socket event handlers and do protocol-specific
testing:
THttpTesterSocket = class(TWSocket) // with http event handlers
...
end;
TSmtpTesterSocket = class(TWSocket) // with smtp event handlers
...
end;
TServerTester = class(TObject) // A common master tester class
Sockets: TObjectList;
...
end;
Or, design 2. Have one simple class derived from TWSocket, or just use
TWSocket
for socket, no event handled in this class. And have a base Tester class
to create sockets. This class declare socket event handlers for the
sockets it creates. Then derive protocol-specific Tester classes and
override the event handlers:
TTesterSocket = class(TWSocket) // very simple no event handlers
...
end;
TServerTester = class(TObject) // create and delete sockets for one
Sockets: TObjectList; // protocol, dummy event handlers)
...
end;
THttpServerTest = class(TServerTester) // with event handler
implementation
...
end;
TSmtpServerTest = class(TServerTester) // with event handler
implementation
...
end;
I'm not very clear about which is better for this job. I'm open
to other suggestions as well.
--
Thanks!
Jack
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://www.elists.org/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be