- From: cowwoc <cowwoc@bbs.darktech.org>
- Date: Fri, 11 Apr 2014 16:47:36 -0400
- To: public-ortc@w3.org
Robin, I think you should consider the Builder design pattern as well, since it is related. I care more about readability than "consistency with other APIs"... but the benefits still need to outweigh the cost. There are definitely benefits of applying these on a per-case basis. The question is whether it makes sense to apply them across the board. I'm not sure. Gili On 11/04/2014 2:13 PM, Robin Raymond 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 Friday, 11 April 2014 20:48:17 UTC