Building a Decision Matrix - PowerPoint PPT Presentation

1 / 7
About This Presentation
Title:

Building a Decision Matrix

Description:

This GUI could exist in a number of different states but only certain states ... UFMatrix := TDecisionMatrix.Create(nil); UFMatrix.DefaultResult := False; ... – PowerPoint PPT presentation

Number of Views:424
Avg rating:3.0/5.0
Slides: 8
Provided by: peterr99
Category:

less

Transcript and Presenter's Notes

Title: Building a Decision Matrix


1
Building aDecision Matrix
Pete Sykes
2
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 didnt want to be
    responsible for maintaining it!

3
The problem
  • 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

4
For example
5
Could be coded as
  • AllowAction False
  • if UserType Guest then
  • if UserAction Read Data then
  • AllowAction True
  • if UserType Data then
  • if UserAction Sign In then
  • AllowAction True
  • else
  • if UserAction Read Data then
  • AllowAction True
  • else
  • if UserAction Update Data then
  • AllowAction True
  • and so on

6
To achieve the same in DecisionMatrix
  • UFMatrix TDecisionMatrix.Create(nil)
  • UFMatrix.DefaultResult False
  • UFMatrix.SetResult(Guest, Read Data, True)
  • UFMatrix.SetResult(Data, Sign In, True)
  • UFMatrix.SetResult(Data, Read Data, True)
  • and so on
  • then
  • AllowAction UFMatrix.CheckResult(Admin,
    Update Data)

7
With DecisionMatrix
  • All the complicated stuff is done in the setup
    phase
  • 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
Write a Comment
User Comments (0)
About PowerShow.com