Re: Not using dependency injection - how do I share services around?

2013-05-15 Thread Colin Yates
Thanks Jason, I will take a look. On Sunday, 12 May 2013 01:27:11 UTC+1, Jason Wolfe wrote: Hi Colin, This is one of the reasons we created graph: https://github.com/prismatic/plumbing which is a general declarative mechanism for describing complex function compositions. There's not an

Re: Not using dependency injection - how do I share services around?

2013-05-15 Thread Colin Yates
Nice videos - thanks for the heads up. On Saturday, 11 May 2013 11:40:04 UTC+1, abp wrote: Well, you could also watch Stuart Sierras talks on structuring functional programs: Clojure in the Large http://vimeo.com/46163090 Thinking in Data Functional Design Patterns

Re: Not using dependency injection - how do I share services around?

2013-05-11 Thread Sean Corfield
Korny mentioned java.jdbc and I figured that was a good in to talk about how we use it at World Singles. Even with the old API we used a function in a specific namespace that returned the data source (in fact it returned a pooled data source, using c3p0). Behind the scenes, we actually use an atom

Re: Not using dependency injection - how do I share services around?

2013-05-11 Thread Chris Ford
Sounds to me like there's enough meat in this topic for someone to consider submitting a talk to the upcoming EuroClojure http://euroclojure.com/2013/ or Clojure/conj http://clojure-conj.org/ on what Clojure means for DI. It's a commonly asked question, and it could be an opportunity for The

Re: Not using dependency injection - how do I share services around?

2013-05-11 Thread Colin Yates
Yes it does, thanks. It is amazing how much you can do in the typical spring/hibernate stack with a decent IDE without engaging your brain :). Clojure involves far less ceremony and really does expose you to the raw elements of your problem domain and make you think. This is of course a good

Re: Not using dependency injection - how do I share services around?

2013-05-11 Thread Jimmy
Do any of the clojure books cover this topic? -- -- 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

Re: Not using dependency injection - how do I share services around?

2013-05-11 Thread Jimmy
Do any of the clojure books cover this topic? -- -- 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

Re: Not using dependency injection - how do I share services around?

2013-05-11 Thread abp
Well, you could also watch Stuart Sierras talks on structuring functional programs: Clojure in the Large http://vimeo.com/46163090 Thinking in Data Functional Design Patterns http://www.infoq.com/author/Stuart-Sierra On Saturday, May 11, 2013 10:48:02 AM UTC+2, Colin Yates wrote: Yes it

Re: Not using dependency injection - how do I share services around?

2013-05-11 Thread Colin Yates
Not specifically, nope. On 11 May 2013 10:37, Jimmy jimmy.co...@gmail.com wrote: Do any of the clojure books cover this topic? -- -- 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

Re: Not using dependency injection - how do I share services around?

2013-05-11 Thread Jason Wolfe
Hi Colin, This is one of the reasons we created graph: https://github.com/prismatic/plumbing which is a general declarative mechanism for describing complex function compositions. There's not an awesome public example yet, but we use Graph at Prismatic to build our production services, where

Not using dependency injection - how do I share services around?

2013-05-10 Thread Colin Yates
(newbie, getting better each day!) I assume we all know DI. Through the use of a central registry I can register a service (a bean in a Spring bean factory for example). I also define consumers of that service in the same registry passing in the configured *instance* of that service. In

Re: Not using dependency injection - how do I share services around?

2013-05-10 Thread Chris Ford
A good question. One way is to use partial application to bake the data source into a fn: (def read (partial read-from-db *data-source*)) On 10 May 2013 14:04, Colin Yates colin.ya...@gmail.com wrote: (newbie, getting better each day!) I assume we all know DI. Through the use of a central

Re: Not using dependency injection - how do I share services around?

2013-05-10 Thread Ben Mabey
Hi Colin, On 5/10/13 5:04 AM, Colin Yates wrote: 1) to use (defonce *data-source*...) so that every body who requires that ns gets the same instance? While this has been done I view this as an antipattern. The big problem with this approach is that you now can only have a single

Re: Not using dependency injection - how do I share services around?

2013-05-10 Thread Colin Yates
Thanks both - some good suggestions. After years of Java I am loving how 'symmetrical' everything is in Clojure (I guess in Lisp). Thanks for the library references. On 10 May 2013 14:14, Ben Mabey b...@benmabey.com wrote: Hi Colin, On 5/10/13 5:04 AM, Colin Yates wrote: 1) to use

Re: Not using dependency injection - how do I share services around?

2013-05-10 Thread Timo Mihaljov
On 10.05.2013 14:04, Colin Yates wrote: 2) to provide a 'get-ds' accessor which returns a new instance and rely on passing that service along to every function that needs it? For what it's worth, some people in the OO community, most notably Nat Pryce and Steve Freeman of Growing

Re: Not using dependency injection - how do I share services around?

2013-05-10 Thread Colin Yates
Thanks Timo; Interesting links. Loving Clojure, but boy is it challenging the stuff I have been doing for the past how-ever many years :). On 10 May 2013 20:14, Timo Mihaljov t...@mihaljov.info wrote: On 10.05.2013 14:04, Colin Yates wrote: 2) to provide a 'get-ds' accessor which returns a

Re: Not using dependency injection - how do I share services around?

2013-05-10 Thread Korny Sietsma
It's interesting to note that clojure.java.jdbc used to use our first option - they had a dynamically bound var *db* that you assigned using the (with-connection) macro. As of version 0.0.3 this has been deprecated in favour of something like your second option - now you pass an explicit db