[Development] fixing name of QNetworkAccessManager::createRequest

Peter Kümmel syntheticpp at gmx.net
Sun Jan 15 15:25:46 CET 2012


On 13.01.2012 14:10, Mathias Hasselmann wrote:
> Am Freitag, den 13.01.2012, 13:00 +0000 schrieb Giuseppe D'Angelo:
>> On 13 January 2012 12:32, Mathias Hasselmann<mathias at openismus.com>  wrote:
>>>> what about the slightly more garden-variety approach of deprecating
>>>> the old one and introducing a new method?
>>>
>>> Maybe we should check the premise of this discussion first.
>>> Does that method really have the wrong name? It is called
>>> "createRequest" and after all it causes creation of a network request.
>>> Now this network request is just an internal object, and not exposed to
>>> the API user. Instead the watchable reply object is returned in advance.
>>
>> The problem is that it doesn't match the Qt namings for the relevant
>> classes... createRequest takes a QNetworkRequest (which is a
>> "description" of the request that should be made), starts making the
>> underlying network request as you described, but then also creates and
>> returns a reply (QNetworkReply). Bikeshedding?
>
> Surely startRequest() would have been a better name.
> But really not sure it is worth the hassle of changing it.
> Still Robins suggestions shows a practical approach.
>

'create' sounds like 'new', therefore

     QNetworkReply* r = x->createRequest(..);

looks like

     int* i = new char;

which is indeed strange.

But to think first about what "createRequest" really does is a good idea:
It not only creates a request, it also sends it, so why not rename it to
'doRequest' or something similar which is different to 'createReply'
which is as misleading as 'createRequest'.

A new name would stop the compiler and there will be no silent bugs.
And replacing a simple function name isn't that hard, so there is no
need for a 'migration path' via deprecated functions.

Peter



More information about the Development mailing list