On Mon, Jul 10, 2017 at 1:35 PM, Luke Horton <luke.w.hor...@gmail.com>
wrote:

> This is probably not clojure specific, but it’s a problem for which i’ve
> never really found a satisfying in other languages. Maybe clojure has a
> better opinion on the matter?
>
> How does one evolve/change data (entities) in a system over time without
> also having to change every piece that touches that data?
>
> e.g. if I had an entity “foo”:
> {:a 'a
>  :b 'b
>  :c {:d 'd}}
>
> and I wrote a nice `clojure.spec` for that foo entity, and maybe
> formalized it into a record, anything that needed the data could read
> straight from built in functions:
>
> (get/get-in/... keyword)
>
> I could move one step more formal and write “accessors” for compound data,
> i.e.
>
> (defn get-a-compound [foo] (str (:a foo) (:b foo) (get-in foo [:c :d])
>
> Now at some point I have to change my entity because a business
> requirement changed, or the domain model wasn’t correct the first time.
> Must now everything that touches foo and follows the clojure.spec
> "contract" of the data shape change?
>

I think there's a big difference between "evolution" and "change". If you
add a new field to your map, that's an evolution, and it does not affect
code that works with the original map (evolution preserves useful stuff).
Adding a beak that can crack nuts does not affect ability to fly using your
wings.  But discovering that your model was wrong in the first place is a
different story.  In that case, everything that uses your model is also
wrong, so it stands to reason that changing your model will require
changing all of the code that uses it.  The original, "wrong" model is an
evolutionary dead-end.  The correct version is not really a modification of
the wrong version, it's a different thing.

Using getters/setters (more generally, information hiding) is an
anti-pattern in Clojure, afaik.

-- 
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