Newbie so go gentle please :).  

I am an experienced OO Java developer (decade +) considering jumping fence 
to a functional language, and clojure is pretty high up on the list for a 
number of reasons.

I am so used to defining everything as objects which are sealed units of 
state and behaviour that I am struggling to see how to solve the same 
problem with clojure.  I desperately wish somebody would write a "domain 
driven design with clojure" :).

In brief, in OO state is exposed via a well defined API.  That state may be 
simple properties (values) or it may be calculations (functions).  And 
critically, the decision as to whether it is a value or a function is an 
implementation concern.  The Java Bean spec defines accessors for properties 
of a class, behind which lies the logic of how to retrieve that state.  So, 
the very common Person class will expose get/setName(), get/setAge() etc. 
and as a consumer I have no idea how the results are calcualted.

In Clojure, if I understand correctly, the preferred way would be to use a 
map (or defstruct) with keys such as :name and :age.  These are then 
retrieved as (person :name) and (person: age) etc.  

My question is if I suddenly decided that one of those values is best 
implemented as a calculation, how can I seamlessly implement that.  By 
seamless I mean implement it without updating any consumers of a person? 
 For example, if I changed the age property to be  the result of a function, 
I could either replace the value of age with a function that calculates age 
or write a function(person)->age.

Both of those are disruptive to the consumers of person.

I understand that clojure is about explicitly distinguishing between state 
and functions, but I see this as a high price to pay.  Have I missed 
something?  The OO in me is saying "well, never introspect a map directly, 
rather provide get-X(person) functions" but that is very very noisy.

That's enough for now - this is, I expect, the first of many cries for help 
:)

Thanks in advance to all who reply!

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

Reply via email to