Fork me on GitHub
#re-frame
<
2021-11-14
>
Thomas Meier18:11:11

When setting up a db with different but similar names for things, is it smarter to keep the key name similar to the thing it's modeling or just use a generic name? Example:

(def {:posts [{:post-title "whatever"}] :pages [{:page-title "whatever"}]})
;; versus
(def {:posts [{:title "whatever"}] :pages [{:title "whatever"}]})

emccue18:11:07

eh - depends

emccue18:11:21

i would say choose between :title , :post/title and

1
emccue18:11:02

:post-title is namespacing anyways

thheller18:11:12

I prefer long specific names, even with namespaces. :post-title or :. generic names can cause problems with conflicts which can get annoying (defn fun [{:foo/keys [title] :bar/keys [title]}] ...)

pavlosmelissinos19:11:17

1. maybe that's a sign that the two titles should be worked on separately 2. if you really need both in the same function, what's wrong with (defn fun [{foo-title :foo/title bar-title :bar/title}] ...) ?

thheller05:11:58

if you like doing that you are welcome to do it. I prefer the long variant.

pavlosmelissinos08:11:05

Sorry, sometimes I get too passionate about design decisions. I didn't mean to sound derisive, I was genuinely asking:slightly_smiling_face: