2007-03-11

Dependency Injection and Rule Engines

Nick Malik compared and contrasted Dependency Injection and Rule Engines a couple of days ago. The way I read his conclusions is that it's (almost) never a good idea using a Rule Engine because you can (almost) always achieve the same sort of dynamic functionality from using a Dependency Injection framework.

Both Charles and Rajgo have written very good responses and I won't repeat the arguments here, but... (being a smug-lisp-weenie) I can't help but to think of this in terms of Greenspun's Tenth Law:

"Any sufficiently complicated C or Fortran program contains an ad hoc, informally-specified, bug-ridden, slow implementation of half of Common Lisp."
It might be a good idea developing your application using the Dependency Injection Pattern but if you really need to use (and should have used) a Rule Engine you'll probably end up re-implementing a lot of things (tricky things I might add) that you could have had support for out of the box and that you probably didn't think you needed when you started out. Things like forwards and/or backwards chaining, universal and/or existential quantifications and logical dependencies between facts/objects come to mind. There's more of course but I think you've got the idea.

Inga kommentarer: