This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-06-20
Channels
- # beginners (106)
- # boot (25)
- # cider (2)
- # cljs-dev (100)
- # cljsjs (1)
- # cljsrn (8)
- # clojure (90)
- # clojure-brasil (1)
- # clojure-dev (7)
- # clojure-greece (2)
- # clojure-italy (4)
- # clojure-madison (1)
- # clojure-russia (15)
- # clojure-serbia (15)
- # clojure-spec (13)
- # clojure-uk (32)
- # clojurescript (88)
- # cursive (19)
- # datascript (13)
- # datomic (32)
- # defnpodcast (1)
- # dirac (43)
- # euroclojure (1)
- # graphql (5)
- # hoplon (11)
- # immutant (1)
- # jobs (6)
- # lein-figwheel (2)
- # liberator (2)
- # luminus (14)
- # lumo (22)
- # off-topic (12)
- # om (9)
- # onyx (49)
- # parinfer (45)
- # precept (4)
- # protorepl (2)
- # reagent (14)
- # ring-swagger (3)
- # sql (1)
- # test-check (58)
- # timbre (3)
- # untangled (86)
Sorry but after all the discussion about encapsulation, I still find that hiding (encapsulating) internal implementation of "complex" mechanisms (not silly field values like in Java) is a reasonable thing for helping others/self use of components without shooting one's own foot or scanning dozens of fn
s to figure what is meant to be used from the outside
matan: well, you’re arguing against something I didn’t say. I didn’t say that all encapsulation was bad, I said needless encapsulation of data is bad and OO as typically practiced encapsulates all data.
When I have a complex side-effecting machine with a simple use interface, I reach for a protocol. You can also convey intentions about var usage with namespace design.
@U04V4HWQ4 what’s an example of using namespace design? I might be overthinking the meaning, but I haven’t heard that term before.
Maybe better examples but one that jumps to mind is core.async, where there is a public api (clojure.core.async) and a bunch of impl namespaces (e.g. clojure.core.async.impl.buffers)
matan: note that even private vars are still accessible - anyone can obtain and use them still. The private meta is really more documentation than encapsulation.
that’s a good insight; i think the clojure difference is probably avoiding 1. colocating state with logic in memory 2. requiring encapsulated fn A to bring B, C, D, E, F and all their dependencies with it
@matan this belongs in #off-topic since this is not about clojure.spec (or even clojure itself) FYI
How would I rewrite this to avoid duplication? (s/def ::PrimaryContact (s/keys :req-un [::FirstName ::LastName ::Email] :opt-un [::Title ::Company ::Type ::Phone ::Fax])) (s/def ::SecondaryContact (s/keys :req-un [::FirstName ::LastName ::Email] :opt-un [::Title ::Company ::Type ::Phone ::Fax]))
(s/def ::Contact (s/keys :req-un [::FirstName ::LastName ::Email]
:opt-un [::Title ::Company ::Type ::Phone ::Fax])
(s/def ::PrimaryContact ::Contact)
(s/def ::SecondaryContact ::Contact)
ah, well that's easy... thanks!