|
|||||||||||
|
Re: Connection::connect() interface is changing
From: Alex Burton <alexibu(at)mac.com>
Date: Sun Jul 15 2007 - 09:39:14 EDT
I think a better option would be to make a ConnectionFactory class like this:
class ConnectionFactory
virtual Connection createConnection() const = 0; }; with sub classes like this :
class TCPConnectionFactory : public ConnectionFactory
{
TCPConnectionFactory(const TCPConnectionParms &); Connection createConnection() const; }; I work with a lot of code where if a connection fails, the software needs to keep trying to do what it was doing so that when the fault is rectified the program starts working again by itselft. For this to work I create a connection whenever I need to do something, and don't just have the same connection open. In this type of code the above is useful. A reference to some ConnectionFactory can be passed deep into some code without it needing to know how exactly connections are established. I realise this may be a bit more OO than most c++ programmers will like, and that Connection probably isn't copyable (auto_ptr<Connection> ? ) so maybe just different functions that produce a Connection or different ctors on Connection, I don't thin there is a need for introducing different types of connection based on how they were created. Alex On 14/07/2007, at 2:50 PM, Warren Young wrote: > Warren Young wrote:Received on Sun Jul 15 09:39:39 2007 This archive was generated by hypermail 2.1.8 : Thu Aug 02 2007 - 01:56:49 EDT |
||||||||||
|
|||||||||||