On 23 August 2017 at 03:58, Timothy Baldridge <tbaldri...@gmail.com> wrote:

> Put let's take that and look at it under a engineering lens a bit:
>
> >> For example, a series of events that represent a player's moves in a
> card game:
> >>
> >>  [:card/draw :9h]
>
> You have an ad-hoc encoding of data here now. Expand it out a bit, and
> make it machine readable instead of preferring ease of writing and you get:
>
> {:player/action :card/draw
>  :card/number :9
>  :card/suit :hearts}
>
> Much easier to introspect, and extensible as future data just flows
> through without existing code breaking because you add extra data.
>

But possibly over-engineered. Suppose that the only function we want to
produce is:

  (cards-in-hand events)
  => #{:9h :qh :7d}

If we have a function that returns [k], [v] or {k v}, then I have a hard
time buying the idea that the input to the function should be more complex
than [[k v]].

If the scope of the data is not so constrained, then sure, use a map.

>> I've also found it a useful pattern for data access:
> >>
> >>  [:data/found "Bob"]
>
> I've worked with systems that have done this, and I really dislike it.
> Because now I have to zip the inputs of a function with the outputs if I
> want a composable system usable in pipelines and the like.
>
> What's much better:
>
> {:op/status :success
>  :data/found "Bob"
>  :data/key "444-434-3323"
>  :server/ip ....}
>
> Now not only do I know what data I got, but where it came from, the key I
> originally used, etc.
>

Which is useful only if you plan on using that additional data. If you are
only ever interested in the key and value, and the function is internal,
why dress it up?

-- 
James Reeves
booleanknot.com

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to