> On Jan 24, 2018, at 3:54 PM, Jens Alfke <[email protected]> wrote: > > When there are a lot of optional properties for creating an object, it gets > awkward to stuff all of them into one constructor/initializer method, so you > create an object to hold the properties and then pass that to the constructor.
I agree with the principle, and am on board with the notion of a configuration object. But having to chain together a pile of methods to populate it, rather than simply exposing properties, feels needlessly unwieldy in my opinion. Perhaps it's is a known issue, but the examples currently shown at https://developer.couchbase.com/documentation/mobile/2.0/couchbase-lite/swift.html don't work. For example, to set up a replicator, it seems I'm forced either to use the method-chaining builder pattern previously discussed, or else use the "CBL-" named counterparts: let config = ReplicatorConfiguration(database: cblDatabase, target: URLEndpoint(url: url)) // fails; no initializer available for ReplicatorConfiguration let config = CBLReplicatorConfiguration(database: cblDatabase, target: CBLURLEndpoint(url: url)) // works I'm a little confused as to why the CBL-named classes and the non-CBL (Swift-named) classes are even available. (It's a Swift-only project so far, and I've imported CouchbaseLiteSwift via CocoaPods. I would have though that bridging would have removed a layer of the redundancy, but admittedly I'm not too expert in ObjC/Swift bridging.) > Yeah, it was like this recently. But some developers would modify the > configuration after creating the Database from it, and then asking why their > configuration wasn’t applied. But DatabaseConfiguration is a struct, and in Swift, structs have "value" semantics. Therefore it is incorrect to expect that modifying a struct -- a copy of which was previously handed to another object -- should have any future effect. Accordingly, it seems unreasonable to penalize the programmer at init time in order to protect against such a mistake. -ben -- You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/59DEA6F4-0BB4-4119-AAD5-FC96C303C2E0%40kashoo.com. For more options, visit https://groups.google.com/d/optout.
