Notes
Slide Show
Outline
1
Literate Specification:
A Framework for Documenting and Implementing Business Rules in the Database



Alfredo Torrez
Project ILACO II, Bolivia
  • ..., make known to them the design of the temple --its arrangement, its exists and entrances-- its whole design and all its regulations and laws. Write these down before them so they may be faithful to its design and follow all its regulations.
  •  Ezekiel 43:11
2
 The Literate Specification Language
  • This language:
  • Is a simplified version of a literate language. It lets organize the business’ knowledge in a textual manner, with subtle syntax impositions


  • allows to obtain units of specification code that are between the IMPLEMENTATION CODE and the BR DECLARATION


  • Is oriented to specify Business Rules (BR), the Transformations and the Life Cycle of an Entity


3
The Business Rules
  •     A Business Rule contains three kinds of knowledge:
    • Actions, that refer to the knowledge of ‘How’ to do something
    • Decisions, that relate to the knowledge of ‘When’ the actions will be applied
    • Entities, that identify to ‘Whom’ the actions and decisions will affect and will be applied to
  •     According to the hierarchy of execution and application, the BR have been classified in high, top, middle and low level rules
4
The Life Cycle of an Entity
  •     It is a model that defines the entity’s behaviour, since it is created until it is removed definitively. This model is described as a states machine,  extended to represent different types of Business Rules
    • States are rules that define the moments in which an entity will be transformed in other one
    • Transformations are rules that define the most important events that might occur over an entity
    • Transitions are rules that prevent improperly usage of the transformations over an entity.

5
Language Features
  •     It uses five tags for remarking


  •     It has three sentences


  •     It intermingles text among the tags


  •     This language, with the tags, is trying to encapsulate and hide the specific knowledge, nevertheless, with the text, it is trying to clarify the pinpoints made with the tags


6
Language Tags
Directive and Guide tags
  •     (  ) Directive tag is used to point out the decision criteria and condition rules. The & operator is used for joining decision criteria
7
Language Tags
Rule Tag
  •     <  > Rule Tag is taken into account to emphasize actions and determinations
8
Language Tags
Pattern, End and Loop Tag
  •     {  } Pattern tag is used to arrange other tags including itself within valid rule chunks
9
Combining Tags
for building patterns
  •     Sequence
10
Combining Tags
for building patterns
  •     Case
11
Language Sentences
lifecycle sentence
  •     In relation to a table, it lets define: the records’ states;  the table’s transformations; the transition constraints and the default rules
12
Language Sentences
transformation sentence
  •     Lets program the top level rules to be applied over a table’s records
13
Language Sentences
rule sentence
  •     Lets organize the knowledge (actions and decision structure) implied in a rule
14
Bank Account Entity’s Life Cycle
Life Cycle Literate Specification
  • lifecycle BANK_ACCOUNTS {
  •    (TYPE_OF_RULE)
  •    [STATES] {
  •       <OPENED, ‘The Account is empty and recently created’>
  •       <PREPARED, ‘The Account is prepared for entering in operation’>
  •       <OPERATING, ‘The Account is operating’>
  •       <SUSPENDED, ‘The Account is out of operation’>
  •       <CLOSED, ‘The Account is closed’>
  •    }
15
Bank Account Entity’s Life Cycle
... Continuing
  •    [TRANSFORMATIONS] {
  •       <OPEN, ‘Create a new account’, INSERT>
  •       <MODIFY, ‘Modify a new account’, UPDATE>
  •       <ELIMINATE, ‘Delete a new account definitively’, DELETE>
  •       <PREPARE, ‘Prepare for entering a new account ...’, UPDATE>
  •       <RESTORE, ‘Restore the account preparation’, UPDATE>
  •       <ENABLE, ‘Enable a prepared account for operating’, UPDATE>
  •       <DEPOSIT, ‘Propagate the deposits to an operating ...’, UPDATE>
  •       <WITHDRAW, ‘Propagate the withdrawals to an ...’, UPDATE>
  •       <SUSPEND, ‘Suspend an operating account’, UPDATE>
  •       <RESUME, ‘Resume a suspended account’, UPDATE>
  •       <CLOSE, ‘Close a suspended account’, UPDATE>
  •    }
16
Bank Account Entity’s Life Cycle
... Continuing
  •    [TRANSITIONS] {
  •       <START, OPEN, OPENED>
  •       <OPENED, MODIFY, OPENED>
  •       <OPENED, PREPARE, PREPARED>
  •       <PREPARED, UNPREPARED, OPENED>
  •       <PREPARED, RESTORE, OPERATING>
  •       <OPERATING, DEPOSIT, OPERATING>
  •       <OPERATING, WITHDRAW, OPERATING>
  •       <OPERATING, SUSPEND, SUSPENDED>
  •       <SUSPEND, RESUME, OPERATING>
  •       <SUSPEND, CLOSE, CLOSED>
  •       <OPENED, ELIMINATE, END>
  •    }
  •    [DEFAULT RULES] {
  •       <control the permissions and register audit information>
  •    }
  • }
17
Bank Account Entity’s Life Cycle
Transformation Literate Specification
18
Rule Literate Specification
  • rule (the information of the owner of the account has been changed) {
  •    (the first name is changed) <return TRUE>
  •    (the last name is changed) <return TRUE>
  •    (the telephone number is changed) <return TRUE>
  •    <return FALSE>\
  • }
19
The Text inside of the Specification
  • transformation WITHDRAW {
  •    When withdrawing a certain amount of money from an account, the
  •    following BEFORE ROW and AFTER STATEMENTS actions or controls must
  •    take place according to the (MOMENT & LEVEL):
  •    when it is [BEFORE ROW] then, the engine must: {
  •       <check the user’s permission over transformation>,
  •       <check the transformation’s permissions for changing the ...>,
  •       <validate the column’s values> and
  •       <deduct the quantity withdrawn from the account’s balance>
  •    };
  •    finally, when it is [AFTER STATEMENT] then, the engine must {
  •       <save audit information at record level>
  •    }.
  • }
20
Language’s Abstract Machine
  •      This machine supports creation, modification and elimination events. Each one of them transform an entity from current state to another state individually or collectively.


  • This machine works as a control and application mechanism of BR. It is in charge of constraining the inappropriate application of the transformations through a state control mechanism.
21
Language’s Abstract Machine
22
Documentation Framework
  •      The documentation is based on the rule, transformation and lifecycle sentence of this  language
  •      The language’s compiler lets obtain and store enough information for generating any kind of documentation


23
Framework’s Table Scheme
  •      The information obtained from lifecycle, transformation and rule sentence is stored in the next table scheme
24
Implementation Framework
  •      It is based on the Language’s Abstract Machine which is implemented as:
    • Twelve triggers by which the insert, update and delete events are implemented


    • A control package in which the state control mechanism are defined


    • A PL/SQL table by which the machine’s tapes defined in the control package is implemented


25
BR Implementation
  •      The BR are implemented as:
    • BR packages, in which the top, middle and low level rules procedures/functions are defined


    • Database tables, where the transitions constraints are stored for enacting in runtime


    • Procedures, by which each transformation declared in the control package are implemented


26
Experiences and Conclusions
  •      In our case the development methodology has been changed
      • the applications have to be thought in terms of BR
      • the analysts and business rule experts are and will be more involved in the development and maintenance of BR specifications

  •      The language lets implement many types of BR


  •      Some problems gain importance
      • the generation of the specific PL/SQL code for low level BR
      • the dynamic on/off switching of the BR
      • the BR that affect recurrently a table
27
Thanks for your attention!   
Questions & Answers
  • Contact Information
    • e-mail:      Home : atorrezgaray@hotmail.com
    •                  Work  : atorrez@ilaco.gov.bo
    • phone:      Office : (591-2) 200822
    •                  Cell     : (591-15) 57322