- From: cowwoc <cowwoc@bbs.darktech.org>
- Date: Wed, 30 Apr 2014 13:27:56 -0400
- To: public-webrtc@w3.org
- Message-ID: <5361329C.2010401@bbs.darktech.org>
On 30/04/2014 10:43 AM, Jan-Ivar Bruaroey wrote: > >> >> I think setConfiguration(RTCConfiguration) is preferable in the sense >> that you don't want to end up with PeerConnection.getConfiguration() >> returning a value that doesn't actually correspond to the current >> PeerConnection state. >> >> If you use the Builder design pattern, you could do even better: >> >> PeerConnection.getConfiguration().changeSomething().apply() >> >> where PeerConnection.getConfiguration() returns a copy-on-write >> configuration object and apply() updates the PeerConnection, >> otherwise the object is discarded and never used. > > Dictionaries already address the telescoping constructor problem, so > while I'm a fan of the builder pattern, it seems redundant here. The Builder pattern allows you to implement copy-on-write. Dictionaries require you to always return a copy, regardless of whether it's used. The Builder is better suited to changing one or two properties and applying the same, all on a single line of code; whereas dictionaries require you to spread this out over multiple lines. I think Dictionaries are great for the initial configuration, but for deltas I think Builder does a better job. Technically speaking, we can do both: 1. PeerConnection's constructor or setConfiguration() can take a dictionary for the initial configuration. 2. getConfiguration() can return a builder for reading existing values and applying minor deltas. Gili
Received on Wednesday, 30 April 2014 17:29:03 UTC