What Not How: The Business Rules Approach to Application Development

May 8th, 2002 by Tony in * commentary, * one-offs

I spent an hour or so in MIT Coop reading this book, and taking copious notes. Date’s central thesis is that the trend in computing is always from Procedural to Declarative, from ‘How?’ to ‘What?’.

The biggest bottleneck in creating applications is turning the requirements into a functional system. His solution: eliminate the code, and merely state your business rules declaratively.

He spends quite a lot of time explaining how this is not the same as writing lots of event handlers in a database (they’re difficult to write, even more difficult to debug, and are usually database events (‘do something when this record is updated’), rather than business events (‘do something when an order is placed’).

I found his taxonomy of rules very handy. In the simplest form, all rules are either Constraints or Derivations.

There three forms of Constraints:

  1. State Constraints (Total Owed <= Credit Limit),
  2. Transition Constraints (You can move from Married to Divorced or Married to Widowed, but not from Widowed to Divorced, or Divorced to Widowed),
  3. Stimulus/Response (IF StockLevel – OrderedQuantity < ReorderLevel THEN reorder).

And two forms of Derivations:

  1. Computation (LineAmount = QuantityOrdered * OrderPrice)
  2. Inference (IF TotalOrders(c) > $100,000 THEN GoodCustomer(c))

If you can write a system that handles all these rules, then you can probably create 95% of business applications in a purely declarative manner.

I’ve been working for the last year on a framework that allows you to create database backed web sites mostly declaratively. You still need to do some Class::DBI set-up, although I’ve gradually made that less and less important, especially if you’re using a self-aware database, but after that you can create 90% of what you need for a reasonably complex site in a single config file. This book has given me lots of interesting ideas as to where I could take this next…

No Comments