Them’s the Rules: Using a Rules Engine to Wrangle Complexity

Micah Breedlove

When dealing with complicated and ever-growing program conditions brought on by new business requirements, it's easy for what was once a small conditional block of code to grow to evaluating hundreds of unique conditions. Unfortunately, much like kudzu, that bad practice begins to creep into other areas of code. Micah Breedlove says that incorporating a rules engine to handle the conditional logic is a great way to reduce the code smells wafting from a multi-hundred line conditional. Converting the conditional into one small block of code which can retrieve and interpret a rule from another source—a database, XML, YAML, or some other repository—alleviates unnecessary logic. Micah presents different approaches to implementing a rules engine including event-driven and direct injection to give a better appreciation for its ability to simplify the growing complexity of conditional statements. Cleaning up conditional logic is an important gateway to writing more concise code which leads to an easier-to-maintain application.

Upcoming Events

Mar 19
Apr 29
Jun 03
Jun 25