Hm, the most common way to encapsulate in clojure is with a closure:

Your account repository would be:

(defn account-repository [connection]
  ;; <- here goes additional constructor logic
  (fn save [account]
    (sql-save connection account))

If the repository has more methods than just save, you can return a map of
functions, or an implementation of a protocol / interface.

In my experience, component is most useful when talking to stateful APIs at
the fringes of the application. There you need lifecycle methods to let the
user (or system) nudge the application from one state to the next,
observing and doing stuff along the edges. But the meat of an application
(calculating what to do) can normally be stateless functions over data.

A recent alternative for when there are only two lifecycle events around a
single updater method (construct, finish, step), are transducers.

hth, kind regards
​

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