
In our ongoing exploration of how to meld the worlds of business rules and requirements, we look at an example use case and see how to extract the business rules.
Separating Business Rules From Requirements
In our earlier article we described one benefit of separating business rules from requirements. That article explored the benefit that we get from spending less time defining requirements and less time interpreting requirements. Ultimately, we spend less time developing our software as a result.
Business rules tend to be embedded in structured requirements artifacts because those rules tend to be uncovered during elicitation activities for the requirements. One very common and powerful artifact is the use case. And business rules often get embedded in use cases. We’ll look at an example.
Use Case Example
In Patterns for Effective Use Cases, by Steve Adolph and Paul Bramble, we find an example that shows several opportunities to embed (or more importantly, to abstract) business rules. The authors (there’s a link to the book at amazon at the top of this article in the Recommended Reading box) do a fantastic job of providing examples, both good and bad, that highlight behaviors common in use case development. It is a great resource, and if you are anything short of a use case expert, you should own this book.
Use Case 6.9, from p.160 of the book is a use case for withdrawing cash from an ATM. I’m retyping and editing it for our example – all mistakes are mine:
Name: Withdraw Cash
Primary Actor: Account Holder
Normal Flow:
- User inserts his ATM card.
- System reads and validates the card information.
- User selects transaction and enters transaction details.
- System validates transaction details.
- User collects cash and withdraws card.
- System updates the account and resets the system.
Finding Rules-Extraction Opportunities
The same normal flow from above is duplicated below, but with bold text to identify places where there is an opportunity to abstract business rules. We will look at each example.
Normal Flow:
- User inserts his ATM card.
- System reads and validates the card information.
- User selects transaction and enters transaction details.
- System validates transaction details.
- User collects cash and withdraws card.
- System updates the account and resets the system.
Looking at each opportunity…
- Validates the card information. What does it mean to validate the information? What information must be on the card? Possibly only the account number. Perhaps both the account number and an encrypted copy of the account number. Since a bank almost certainly maintains unique account numbers, and people’s names are never reasonably unique, the name of the account holder is redundant information – but it may be used as a redundant piece of information in a set of validation rules. Regardless, the validation criteria represent a decision – which is determined by a set of rules.
- Selects transaction. What is the set of possible transactions for the machine? That list of transactions may change over time. Are different types of transactions allowed for different accounts? While not an explicit decision – the list of transactions implies an implicit decision of what transactions the system must support.
- Validates transaction details. There will be validation rules associated with every transaction. What types of accounts can be used to transfer money to other accounts? What are the maximum and minimum withdrawal amounts? And do those vary for account holders (maybe high balance accounts allow larger withdrawals, or maybe account holders can restrict the withdrawal amounts for secondary card holders)? Each possible transaction will have a set of allowable actions / valid details.
- Updates the account. Perhaps service charges are made (or waived) based on a set of criteria. Maybe people with multiple accounts get free withdrawals. Perhaps the fees (charged by the machines) are paid by the bank and credited to the account.
Instead of writing requirements that specify these details, we should abstract out the rules (e.g. “See transaction list XYZ”).
Summary
[Ed: Added 2007-07-17, thanks Bengt for pointing out that this was missing.]
The requirements discovery and elicitation process uncovers both requirements and rules. While not a formal definition, rules are “discrete requirements”, in that they should be managed differently. Rules can be changed independently of requirements – the transaction-validation rules, for example, do not need to be defined in order to write the software, and should be easy to change once the software is written. Rules may represent constraints, as Roger alludes in the first comment in the discussion below – such as regulatory compliance, or fraud-risk policies that are independent of the ATM interface/process design. Rules may also be implicitly reflected, again, as Roger points out – such as a rule that requires an account to be verified prior to processing a transaction.
In all of these cases, the frequency of change, people responsible for the changes, or the impact on consumers of rules and requirements encourages us to abstract the rules from the requirements.

