- From: Justin Uberti <juberti@google.com>
- Date: Thu, 17 Apr 2014 18:41:05 +0200
- To: Robin Raymond <robin@hookflash.com>
- Cc: "public-ortc@w3.org" <public-ortc@w3.org>, public-ortc-contrib@w3.org
Received on Thursday, 17 April 2014 16:41:52 UTC
I'm kind of skeptical about this. Superficially, new Foo vs Foo.create seem like a matter of taste, and in such matters I think we ought to favor consistency. On Fri, Apr 11, 2014 at 8:13 PM, Robin Raymond <robin@hookflash.com> wrote: > > Currently, we've been using constructors to create objects with new Object > pattern. I think we should move to a Factory Method Pattern for object > construction. > > The pros: > - works better for abstract interfaces so what internal object (even > derived) can be created independent of object > - allows more meaningful method signatures, e.g. createWithFooBar(...) or > listen(...) > - allows easier extensions. There's only so many ways to rearrange > parameter orders to get unique method signatures, whereas we can always > extend factory method names > - allows easier creation of singleton / static helper objects used with > other patterns > - better encapsulation > > The cons: > - "new" knowingly creates a new instance > - consistency with other APIs? > - more methods exposed in the interface (but not really since constructor > has as well, it's just more implicit) > > Thoughts? > > -Robin > > >
Received on Thursday, 17 April 2014 16:41:52 UTC