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 Object-Oriented Software[1] fame, advocate[2][3] this approach over using an IoC container. > Option 2 means functions are still pure, but how do you prevent huge > lists of services - i.e. if func-a calls func-b which calls func-c and > func-c needs service-a then func-a and func-b need to access service-a. > Yuck. It also means the main entry point to my application needs to > assemble all of these services up in one go. Here's the punchline from [3]: If I later find that I can’t get access to some component that I think I need, that’s not necessarily a bad thing. It’s telling me that I’m introducing a new dependency and sometimes that’s a hint that a component is in the wrong place, or that I’m trying to use it from the wrong place. The coding bump is a design feedback mechanism that I miss when I can just pull objects out of a container. If I do a good job, I should find that, most of the time, I have just the right components at the time that I need them. [1] http://www.growing-object-oriented-software.com/ [2] http://www.natpryce.com/articles/000783.html [3] http://www.higherorderlogic.com/2011/07/is-dependency-injection-like-facebook/ -- Timo -- -- 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/groups/opt_out.