On Tue, May 19, 2009 at 6:18 AM, Meikel Brandmeyer <m...@kotka.de> wrote:
> I think the idea of decoupling is called "inversion of control"
> or "dependency injection". I'm sure it works for you, but it
> sure did in this (admittedly) simple example. There are
> various ways at passing around parameter:
> - global with binding
> - multi-arity functions
> - keyword functions

Thanks for writing up this example.  You use a number of interesting
techniques.  The technique you used to implement keyword functions is
something  I haven't seen before, so that was especially interesting
to me.  Your multimethod approach was also clever.

Essentially, your solution is to pass all the functions from other
modules as extra parameters, and then thread those extra parameters
through all the calls between functions.  I think that can probably
work (I think it might break down if there are recursive dependencies,
such as the solver depends on the analyzer, and the analyzer also
depends on the solver, but I need to think that through more to be
sure).  The obvious downside is that one must make a fairly radical
restructuring when you're ready to make the transition from your
initial "don't think about swapping out these functions" pass to a
fully modular plug-and-play version.  And it seems that the complexity
grows with the number of functions and/or modules you want to leave
open for extension.

That's why I was mainly looking for solutions that involve globals and
rebinding, because I thought it would "scale better".  But
unfortunately, as pointed out earlier in the thread, those techniques
don't really work for this kind of problem.

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