3 ms·
Rules engines are awesome and are super powerful, but add a layer of complexity that is not inconsequential. I have implemented a lot of rules engines, and rem
by davismwfl 12y ago
Rules engines are awesome and are super powerful, but add a layer of complexity that is not inconsequential. I have implemented a lot of rules engines, and removed a fair number of them too since the late 90's. I generally removed them because they created a dependency nightmare, added crazy complexity and required significant extra test conditions that the application just didn't need to have. This can slow your development down considerably for smaller applications and cause great frustration. Which is not what a rules engine should do.
My basic starting thoughts is that if the rules are well known, change infrequently, have minimal nested chaining and number < 50 or so then I'd opt for having a good design pattern or simple if/else within the code. If you violate any of these tenants, then I'd look at decision tables/trees first, then after that move to a rules engine. Of course, if users are required to write their own then that would also have to factor in to this decision. BTW -- Don't dismiss a good design pattern or even a plug-in pattern as sometimes that is more than enough to solve moderately complex rules without adding additional dependencies or significant development complexity.
If this is an application that will be deployed to third party sites, then again, I generally opt for a balance between the number of dependencies and the application maintenance. If it is deployed behind a website or application where your company controls the environment, then I focus more on flexibility and application maintenance than dependencies.
Also, in a few less common scenario's, I have written very basic purpose built rules engines that solved some of the key issues without creating needless complexity, maintenance or dependency nightmares. Not that I advocate writing libraries/code that already exists, but many times you just don't need a Drools, or ilog rules etc. Also, this is where something like embedded JavaScript is a handy tool as pjungwir also mentioned.