clojuredesign-podcast

leifericf 2021-12-18T09:56:18.050600Z

In episode 22, @nate and @neumann talk about using “flat data structures” and “namespaces keys,” instead of nested data structures. That concept is a bit unclear to me. Does anyone know of a paper or blog post which goes more in depth on this topic, with some code examples?

leifericf 2021-12-19T09:10:00.058300Z

That’s awesome! Thanks for digging those up, @nate!

lodin 2021-12-20T12:19:28.058700Z

Also https://www.youtube.com/watch?v=IS3i3DTUnAI .

lodin 2021-12-20T12:54:16.059Z

I find that there is a lot of nuance to consider with regards to qualified keywords. In particular, context is very important. He touches upon that at https://youtu.be/IS3i3DTUnAI?t=1741 .

neumann 2021-12-20T18:52:41.059200Z

For what it's worth, I've been using namespaced keys for over 3 years now and I still fine them useful in a number of situations. In particular, when I have to mix a number of fields together that come from other sources.

neumann 2021-12-20T18:52:45.059400Z

Eg. player, team, season, etc. You would have :player/id , :team/id, :season/id instead of :player-id, :team-id, :season-id, and such.

neumann 2021-12-20T18:53:47.059600Z

And definitely not the horror of:

{:player {:id 42}, :team {:id 11}, :season {:id 99}}

neumann 2021-12-20T18:55:22.059800Z

In general, the situation where I find them the most useful is when the map is a "bag" of fields from different entities that are all combined together for convenience or correlation (data that has be joined.)

neumann 2021-12-20T18:57:26.060Z

You can do nifty stuff like this:

(merge
  (select-keys player [:player/id :player/name])
  (select-keys team [:team/id :team/name])
  (select-keys season [:season/id :season/year :season/phase]))

neumann 2021-12-20T18:58:45.060200Z

So that would be an expanded record of information about a player that would include more context: the team the player was on (at the time) and the related season.

neumann 2021-12-20T18:59:12.060400Z

@leif.eric.fredheim Let me know if that's helpful!

👍 1
nate 2021-12-18T16:23:44.053300Z

Hey @leif.eric.fredheim, I don't have any blog post links handy, but I do know we've discussed it a bit in this channel. Now that we have the full history searchable I was able to find some links to those discussions.

nate 2021-12-18T16:24:12.054400Z

Jump to that message and look at the thread and other messages in the channel after.

nate 2021-12-18T16:24:46.055100Z

Here is Christoph with an example: https://clojurians.slack.com/archives/CKKPVDX53/p1571075516008300

👍 1
nate 2021-12-18T16:25:34.055800Z

Here's a mention of a Stuart Halloway talk: https://clojurians.slack.com/archives/CKKPVDX53/p1571110664017800

nate 2021-12-18T16:27:23.057200Z

I believe we also talk about namespacing keys in our Maps! Maps! Maps! episode: https://clojuredesign.club/episode/051-maps-maps-maps/

lodin 2021-12-22T13:20:20.060800Z

@neumann Why is the nested data horrible though?