[whatwg] [Notifications] Constructor should not have side effects
stewart.brodie at antplc.com
Tue Jan 29 10:07:34 PST 2013
Glenn Maynard <glenn at zewt.org> wrote:
> On Tue, Jan 29, 2013 at 7:36 AM, Charles McCathie Nevile <
> chaals at yandex-team.ru> wrote:
> > Really? This doesn't seem like a good idea, so I'd be interested to know
> > why. Is there an explanation laid out somewhere?
> Just to ask from another perspective: why doesn't it seem like a good
All the information required to "activate" the object may not be available
at the point at which the object is constructed.
For example, how can you add event listeners to something that doesn't exist
yet? Particularly if you want to use a closure with the new object.
> Having objects that begin their job when constructed simply avoids an
> extra step for the user (telling it to start), and reduces the number of
> possible states (eg. eliminating the UNSENT state), which generally
> simplifies things. Supporting reuse of objects is generally not a useful
> optimization (in my experience), so not supporting it also simplifies
> things a bit. Reducing the number of different-but-equivalent ways of
> doing the same thing is also generally good API design.
I agree - but I don't see what this has to do with separating construction
Team Leader - ANT Galio Browser
ANT Software Limited
More information about the whatwg