List:MySQL++« Previous MessageNext Message »
From:Joel Fielder Date:July 16 2007 8:56am
Subject:RE: Connection::connect() interface is changing
View as plain text  
Warren Young wrote:
> Adding verbosity is exactly the wrong thing.

Actually I'm not so sure about verbosity being bad.  Sure, too much is
too much, but as a general point, I'd say that the ability of users to
immediately understand the interface should be a big factor in its
development as most people will only ever see that, and if it's not
obvious, people find it hard.  A bit of extra typing in exchange for
less noise and less reading of docs is a very fair trade imo.

> I could be talked into something less verbose, 
> but in the same vein, like this:

I do prefer your idea of alternative constructors, but like Alex said,
I'm not sure there's a need for different subclasses (at least as far as
the client code is concerned) although either way is a better solution
than currently exists.  Perhaps the named constructor idiom is an
alternative option for consideration?

class Connection ...
{
public:
	static Connection DomainSockets(path);
	static Connection NamedPipes();
	static Connection TCP(whatever);

private:
	Connection();
}

Connection Connection::TCP(whatever)
{
	// Construct a connection however you like and return it.
	// Perhaps you could have subclasses that are hidden in the
interface,
	// and are only available in the implementation file?
	return TCPConnection(whatever);
}

Usage is the same as you wrote, but this feels nicer if you know what I
mean!

Joel

Thread
Connection::connect() interface is changingWarren Young13 Jul
  • Re: Connection::connect() interface is changingDrew M.13 Jul
    • Re: Connection::connect() interface is changingWarren Young13 Jul
  • RE: Connection::connect() interface is changingYuantu.Huang13 Jul
    • Re: Connection::connect() interface is changingWarren Young13 Jul
      • RE: Connection::connect() interface is changingJoel Fielder13 Jul
        • RE: Connection::connect() interface is changingWilliam F. Dowling13 Jul
        • Re: Connection::connect() interface is changingWarren Young14 Jul
          • Re: Connection::connect() interface is changingWarren Young14 Jul
            • Re: Connection::connect() interface is changingAlex Burton15 Jul
              • Re: Connection::connect() interface is changingPeter Garner15 Jul
              • Re: Connection::connect() interface is changingWarren Young16 Jul
          • RE: Connection::connect() interface is changingJoel Fielder16 Jul
            • Re: Connection::connect() interface is changingWarren Young16 Jul
              • Re: Connection::connect() interface is changingAxel Howind16 Jul
                • Re: Connection::connect() interface is changingWarren Young16 Jul
  • Re: Connection::connect() interface is changingAxel Howind13 Jul
    • Re: Connection::connect() interface is changingWarren Young14 Jul
      • Re: Connection::connect() interface is changingAxel Howind16 Jul
  • Re: Connection::connect() interface is changingAlex Burton13 Jul
    • Re: Connection::connect() interface is changingWarren Young14 Jul
  • RE: Connection::connect() interface is changingJim Wallace13 Jul
    • Re: Connection::connect() interface is changingWarren Young14 Jul