This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-09-22
Channels
- # announcements (11)
- # architecture (7)
- # babashka (26)
- # beginners (314)
- # calva (20)
- # chlorine-clover (1)
- # cider (5)
- # circleci (27)
- # clara (6)
- # clj-kondo (41)
- # cljsrn (6)
- # clojure (120)
- # clojure-berlin (2)
- # clojure-czech (2)
- # clojure-dev (4)
- # clojure-europe (45)
- # clojure-france (4)
- # clojure-germany (1)
- # clojure-nl (5)
- # clojure-uk (20)
- # clojuredesign-podcast (8)
- # clojurescript (6)
- # conjure (42)
- # datascript (5)
- # datomic (21)
- # deps-new (28)
- # duct (1)
- # fulcro (36)
- # graalvm (10)
- # graphql (24)
- # jackdaw (19)
- # jobs (2)
- # jobs-discuss (46)
- # kaocha (6)
- # malli (26)
- # off-topic (21)
- # parinfer (5)
- # re-frame (10)
- # sci (19)
- # shadow-cljs (95)
- # tools-deps (24)
- # vim (3)
Thanks @nate @neumann — I think I finally understand the Builder GoF pattern after hearing your funny hypothetical sorting example! I never really got GoF book when I read it decades ago, and always struggle with all the Google Cloud Java libraries which extensively use the pattern. Starting to get it now, finally!
@U6VPZS1EK I'm happy we could help! The builder "pattern" always makes me a bit crazy. At best it's overcoming a lack of literals in a language. (You can't just write out the contents of a "map", you have to "build" one.) At worst, it's a big mutable mess of something that goes through nonsensical states on its way to actually being something. eg.
SentenceBuilder b = new SentenceBuilder();
b.appendWord("are");
b.prependWord("Builders");
b.appendWord("nuts!")
b.render();
> "Builders are nuts!"
Of course, no one would ever make a "SentenceBuilder" because you'd just use a string literal to write out a sentence. That brings me back to the first point!
This is so great to hear that some of my struggles were legitimate. Honestly, I need to read about the Builder and other GoF patterns more, because it would help me use these Google libraries, who adhere to them so well. I could have saved myself a bunch of time if I realized that. You can see how I struggled for days to get a Firebase instance working here, mostly because I had no idea what I was doing: 😂https://gist.github.com/realgenekim/2d9b14da54e71bb14ffe69afc7947bc8
Yeah, if you do need to deal with OO, I think it does help to understand the GoF patterns. I checked out your gist. I'm always struck by how verbose builders are vs a literal:
(def db (-> (new FirebaseOptions$Builder)
(.setCredentials creds)
(.setDatabaseUrl "")
(.build)
(.getService)))
vs something like
(create-service {:credentials creds, :database-uri ""})