[Development] Common base class for all socket types

Oswald Buddenhagen oswald.buddenhagen at digia.com
Wed Nov 7 11:00:29 CET 2012


On Tue, Nov 06, 2012 at 04:47:58PM -0700, d3fault wrote:
> On 11/6/12, Corentin Jabot <corentin.jabot at gmail.com> wrote:
> > I dont see how the connectTo* methods could be shared, and I don't
> > think it would be a good idea to try to do so.
> >
> I disagree. Having a QList<QAbsrtactSocket*> and then being able to
> iterate over them and connectTo* and disconnectFrom* without knowing
> their type is helpful. You (_developer_) can't know the duration of
> each connection (_user_) either so we could move the traditional
> connectTo parameters into a new constructor and expose them as
> properties as well. Then QAbstractSocket::connectToHost() would have
> no arguments, and we can provide a helper/source-compatible overload
> QTcpSocket::connectToHost(host, port) while we're at it. The base type
> constructor has no arguments and calling the empty connectToHost
> before setting up the properties will just return false.
> 
i tend to agree. in fact, i want to do the same with qprocess' start()
function.
aside from the possible polymorphic use, there is the general advantage
of property-based apis over functions-with-many-arguments apis.



More information about the Development mailing list