This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-02
Channels
- # adventofcode (47)
- # announcements (7)
- # aws (1)
- # babashka (52)
- # beginners (80)
- # boot (3)
- # calva (19)
- # cider (9)
- # cljs-dev (1)
- # clojure (48)
- # clojure-brasil (1)
- # clojure-dev (27)
- # clojure-europe (3)
- # clojure-madison (3)
- # clojure-nl (29)
- # clojure-spec (11)
- # clojure-sweden (1)
- # clojure-uk (49)
- # clojurescript (66)
- # core-async (20)
- # cryogen (4)
- # cursive (13)
- # data-science (7)
- # datomic (5)
- # emacs (30)
- # figwheel-main (11)
- # fulcro (15)
- # graphql (8)
- # jobs (5)
- # joker (17)
- # lambdaisland (1)
- # leiningen (2)
- # malli (2)
- # off-topic (5)
- # pathom (22)
- # re-frame (12)
- # reagent (29)
- # reitit (2)
- # ring (10)
- # shadow-cljs (57)
- # specter (3)
- # tools-deps (22)
- # vim (5)
- # xtdb (7)
Hi. Do you have guidelines, or rules of thumb for naming specs in the following two situations
1. do you rather choose a name that describes the role that the data plays in the enclosing structure (say, ::confirmation-url
), or a name that describes the intrinsic kind of data that key holds (say, ::url
). I tend towards the former, because I think the more descriptive keys read better, but I'm wondering if by doing so I'm not inadvertantly creating private DSL (fragmenting keys when I could have one large overarching key instead and maximise the number of functions that can operate on the data)
2. when do you use symbols rather than keywords to name specs? I tend to use symbols as a kind of zero-arg spec-op, specs that I think of as building blocks, reserving keywords for specs that I would expect to actually appear in maps. Is that a personal quirk of mine?
1. I would say both. Name the generic thing, then have the specific one refer to the generic one.
2. You should never name specs with symbols (those are reserved for function specs)
Lots of places in spec make that assumption and you are likely to be burned by using symbols.
I go back and forth on whether I should register specs or just def the spec object. I’m on a “don’t register” swing now
@favila (s/def ::keyword ...)
vs (s/def 'symbol ...)
-- the code assumes that only function specs use symbols (s/fdef 'foo ...)
Both Alex and I made the same assumption and the OP didn't correct Alex so... ¯\(ツ)/¯
You were correct about what I meant, @seancorfield. Thanks for suggesting using a plain def
when there's no need to s/def
a keyword, @favila.