Right, my point wasn't just about "data change", it was more specifically
about the addition or change of "computed fields".

In Clojure, non-computed fields are usually accessed directly by keyword,
whereas computed fields require an actual API.  This difference in access
style complicates things if you want to change which things are stored
versus computed.

Another complicated scenario that occurs fairly commonly in my work is that
there are computed fields that you want to memoize so that you only want to
compute them once.  For example, imagine that the first time you look up
this customer's zip code, you want to do some lookup against some
time-consuming service to compute the more precise 4-digit extension to the
zip code, and store it as part of the data so you never have to compute it
again.  These sorts of data models are very natural in OO, but require more
thought to pull off successfully in Clojure.

Clojure's modeling capability fits my brain quite well, and I don't see
these things as major problems.  But I feel obligated to point them out to
people coming from an OO background as things to watch out for.

As you say, there is a motto in Clojure: "The data *is* the API."  What
that means is that planning out the data representation becomes just as
important as planning out the API is in an OO language.  In OO, the API
protects you from certain kinds of data changes, whereas in Clojure the
data is more visible, and once people start writing code assuming that
certain fields are going to always be present and stay named the same way,
you're not going to be able to change that without upsetting your users.

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