On Jan 24, 2018, at 2:59 PM, Ben Kennedy 
<[email protected]<mailto:[email protected]>> wrote:

This seems like an insanely baroque syntax. Is it the correct way?

It’s the Builder design 
pattern<https://sourcemaking.com/design_patterns/builder>. 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.

IMHO we’ve currently got too many layers of this — effectively a builder to 
create a builder. There’s some debate going on internally about this, so your 
feedback is helpful.

    let config = DatabaseConfiguration()
    config.directory = "/foo/bar"

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. (Reminds me of the old joke about how you can’t 
idiot-proof anything because people keep finding cleverer ways to be idiots.)

—Jens

-- 
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/DBF16A5F-7805-4926-ADFC-F9A9D870C301%40couchbase.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to