Hi Colin! Welcome to Clojure!

On Wed, Jun 15, 2011 at 11:41 AM, Colin Yates <colin.ya...@gmail.com> wrote:
> 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.

The FP approach certainly takes some getting used to after a lot of
Java! I like the fact that a lot of (post-Java) languages go out of
their way to avoid all the boilerplate get/set methods in various ways
because this is very high ceremony.

I was lucky enough to be exposed to functional programming in the 80's
and then move into OOP in the 90's (with C++ in '92 and Java in '97).
Whilst I am still "unlearning" some OOP habits, I'm more comfortable
with the non-OO approach and dusting off my older programming
approaches. I'm finding, as I introduce more people to Clojure, that
folks without a lot of OOP experience tend to pick up FP much quicker
and aren't as concerned about get/set "encapsulation".

My experience with OOP has been that essential properties of objects
rarely change into computed functions (and derived properties are
computed functions in the first place). That said, of course there are
situations where an essential property needs a function: when you have
side-effects on the get/set operation, such as recording changes, but
I'd argue that is likely to be known upfront. Also given the
preference for immutable data, you're much less likely to use/need
setters.

My suggestion would be to code with raw maps instead of
functions-wrapping-maps and see how things go. By using raw maps
you'll find that a lot of power can be brought to bear with standard
Clojure functions.

As for the age property on Person, that seems to be a common example
given to justify the use of getters but age is a derived property,
based on date of birth, and every real world system I've worked with
that represents people, and needs age, uses a function for it upfront.
So I think that's a bit of a strawman :)

Hope that helps?
-- 
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Railo Technologies, Inc. -- http://www.getrailo.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

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