Building a Decision Matrix Pete Sykes Background During
Building a “Decision Matrix” Pete Sykes
Background During a contract with NATS (National Air Traffic Services) I was responsible, amongst other things, for the design and development of the user interface of the system. This GUI could exist in a number of different states but only certain states were valid for particular types of user. Controls were enabled depending on the functionality valid for each particular state. The business rules for this were easily set down in tabular form but were likely to change a number of times before the project was complete. The initial code to implement the rules was a mess - although I wrote it I didn’t want to be responsible for maintaining it!
The problem… n n Many business rules are easily represented in a tabular form Implementing those rules in code is not necessarily straightforward… …and often involves complex “if. . then. . else” structures… …which can obscure the business logic and make the code difficult to maintain
For example… Gues Admi Syst Data t n em Sign In N Y Y Y Read Data Y Y Y N N N N Y Y N N N Y Update Data Administe r Users Update System
Could be coded as… Allow. Action : = False; Sign In if User. Type = ‘Guest’ then Read Data if User. Action = ‘Read Data’ then Update Data Allow. Action : = True; Administer Users if User. Type = ‘Data’ then Update System if User. Action = ‘Sign In’ then Allow. Action : = True; else if User. Action = ‘Read Data’ then Allow. Action : = True; else if User. Action = ‘Update Data’ then Allow. Action : = True; …and so on… Guest Data Admin System N Y Y Y N N Y Y N N N Y
To achieve the same in Decision. Matrix… Guest Data Admin System Sign In N Y Y Y Read Data Y Y Y N Update Data N Y N N Y Y N N N Y UFMatrix : = TDecision. Matrix. Create(nil); Administer Users … Update System UFMatrix. Default. Result : = False; UFMatrix. Set. Result(‘Guest’, ‘Read Data’, True); UFMatrix. Set. Result(‘Data’, ‘Sign In’, True); UFMatrix. Set. Result(‘Data’, ‘Read Data’, True); …and so on… …then… Allow. Action : = UFMatrix. Check. Result(‘Admin’, ‘Update Data’);
With Decision. Matrix… n All the complicated stuff is done in the ‘setup’ phase… n n n …which lends itself to use of a design-time editor if the class is implemented as a component …or to streaming in from any external source Checking the result of a comparison is a simple one line effort. Code is much more readable (and hence maintainable) Changes in business rules require no code changes The concept is infinitely extendable to allow for n-dimensional matrices
- Slides: 7