Re: [whatwg] [Notifications] Constructor should not have side effects

* Ryosuke Niwa wrote:
>On Jan 29, 2013, at 10:26 AM, Elliott Sprehn <esprehn@gmail.com> wrote:
>> For example you can do var request = new XMLHttp( .... ) at the start of a
>> function, but then later decide you didn't want to send the request, and
>> never call send().
>
>Is that even a valid use case? It seems dubious to instantiate a class 
>named "request" and then not send a request.

`XMLHttpRequest` tries to encapsulate request, response, user agent, XML
parser, and other things into a single object; that's rather dubious in-
deed, but not the calling code's fault. A more typical object design is
the separation I've just mentioned, in Perl for instance you would use a
LWP::UserAgent object where you might set user agent properties like the
User-Agent header or whether the user agent should follow redirects au-
tomatically, and then use that object for many requests. You might pass
it even to other objects in case they need to make any requests on your
code's behalf; and if they don't need to after all, it's quite normal to
dispose of the object without having made any requests.
-- 
Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/ 

Received on Wednesday, 30 January 2013 01:13:26 UTC