James,

The advantages of one style over another are often subtle. And indeed, a 
single object written this way has no real advantage. Poor choice, but it 
was the only code I have written in this way so far. The addition of 
closures only occurred to me while writing this piece of code.

I included the file-channel in the map more on principle than anything 
else. Opinionated Clojure does not try to encapsulate the way Java does, or 
such has been my impression anyway. I do sometimes encapsulate when I want 
the API to be clearer, but otherwise not.

The reason for having this "type of object" at all is that I was going to 
have 3 copies of the same code. Which I find to be a bad thing.

One thing I left out was that in aatree.core I have functions which call 
the "object methods". These functions are implemented like this: 

(defn do-something [arg1 arg2 opts] ((:do-something opts) arg1 arg2))

This gives me a lot of decoupling. opts then is the "object" map. But it 
can be a munged together map of lots of key/value pairs from a lot of 
different "types of objects". Composition goes something like this in its 
simplest form:

(opts -> (db-file-open) (db-cache-open) etc)

I end up composing a lot of things richly but with simplicity. Being new to 
Clojure, I am fascinated by all this. And as I add more and more 
capabilities, it looks like everything stays quite stable--which is exactly 
the opposite of my experience in working with Java objects.

Bill

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