Building%20a%20 - PowerPoint PPT Presentation

About This Presentation
Title:

Building%20a%20

Description:

if UserAction = Sign In' then. AllowAction := True; else. if ... UFMatrix.SetResult( Data', Sign In', True); UFMatrix.SetResult( Data', Read Data', True) ... – PowerPoint PPT presentation

Number of Views:19
Avg rating:3.0/5.0
Slides: 8
Provided by: peterr84
Category:
Tags: 20a | building | signin

less

Transcript and Presenter's Notes

Title: Building%20a%20


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
Guest Data Admin System
Sign In N Y Y Y
Read Data Y Y Y N
Update Data N Y N N
Administer Users N N Y Y
Update System N N N Y
5
Could be coded as
Guest Data Admin System
Sign In N Y Y Y
Read Data Y Y Y N
Update Data N Y N N
Administer Users N N Y Y
Update System N N N Y
  • 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
Guest Data Admin System
Sign In N Y Y Y
Read Data Y Y Y N
Update Data N Y N N
Administer Users N N Y Y
Update System N N N Y
  • 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