Home   :   Matrix Language   :   Model Examples   :   Banking Application

Banking Application Model

 

Introduction

 

The Banking Application model mimics how a real bank account operates from a customer's point of view.

 

The model demonstrates how an object is created asynchronously via a creation event and has a more complicated State Transition Diagram involving seven states.  It also includes the use of several imported events from outside the Banking Application domain.

 

The Banking Application model is taken from the book, Object Lifecycles: Modeling the World in States by Sally Shlaer and Stephen J. Mellor.  The model is described on page 71 and elsewhere in the book.  It appears here in a slightly modified form.

 

 

Overview

 

The model does not self start because it does not contain an ObjectEvent statement.  Instead it waits for an external event that simulates the model to create a Customer object and an Account object.

 

Once an Account is created it can receive various external events which involve money being taken out and paid in.  A further event can cause an Account to be closed if it is not overdrawn.  When the Customer's last Account is closed the Customer is required to leave the bank.

 

 

Model Walkthrough

 

The Domain Bridge Diagram (DBD) shows the banking subject area as a separate domain.  Like the domain, we are not concerned how the external event gets to the entities within or where they come from.

 

Realm:Analysis_Of_Application

 

The Entity Relationship Diagram (ERD) shows Customer and Account entities as you would expect.  The domain also has a Bank Policy entity that holds information that is not associated with a Customer or Account but is required anyway.  Other modeling languages may have this type of data dotted throughout the model as "defines" or constants (magic numbers).  Only relationships that are navigated by Traverse statements are shown since although non-navigated relationships can be interesting and worth noting they are superfluous to a Matrix model description.

 

Domain:Banking_Application

 

The Customer State Transition Diagram (STD) is relatively straightforward.  A Customer is accepted and eventually leaves.

 

Entity:Customer

 

The Accepting New Customer Process Flow Diagram (PFD) shows how a new Account object is created by sending an asynchronous creation event.  This type of event is never directed at an object but is acted on by the target entity as a whole.

 

It is not recommended that PFDs be drawn normally, especially manually, since what they show can be gained with more detail from the Matrix model code.

 

Click on the picture below to get a clearer view of the diagram.

 

Entity:Customer, State:Accepting_New_Customer

 

The Customer Vanishes PFD breaks the relationships to the Account and Bank Policy objects.  All of an object's relationships must be dissolved before the object can be deleted.  The deletion is done automatically by the deletion state.

 

Entity:Customer, State:Customer_Vanishes

 

Below is the Account STD.  Notice that some transitions share the same event name.  It simply means that the same event can be received while the object is in a different state.  The sending object never knows what state the receiving object is in.

 

You must examine the Matrix code to find out what happens when an event is received by a state that does not have a corresponding transition to another state.

 

Since Accounts are created asynchronously the Creating Account state has no diagram.

 

Entity:Account

 

 

Entity:Account, State:Taking_Deposit

 

 

Entity:Account, State:Considering_Withdrawal

 

 

Entity:Account, State:Considering_Check

 

The double headed flow entering the SelectionHead process means that one or more objects are being referenced by the signifier and that the flow itself is multiple context data flow.  This represents a repeating subregion in the Matrix code.

 

Entity:Account, State:Closed

 

 

Matrix Model

 

Click on the Code Map diagram below to get a view of the code.

 

 

 

Expected Output

 

When the Matrix model is executed under the Simulator with all tracing turned off the following display output is produced in the command prompt window:

 

 

    Matrix Model Simulator - Learning Edition - Version 1.0.0

    Development on THU-02-JAN-2014 @ 11:38:09

    Copyright (C) 2014, Dark Matter Systems Ltd.  All rights reserved.

 

    Connection established: MATRIX*CORE - Version 0.5.2

 

$

$ | Banking Application Scenario

$

$ trace all off

$ trace display on

$ trace events on

$ trace states on

$

$ initialise all

$

$ | Steve Opens Account

$ create event creation Banking_Application Customer New_customer "Steve" "Albania" 20.00

 

    Customer Registered

        Full Name: Steve

        Address:   Albania

 

    Account Opened

        Account Number: 10000003

        New Balance:    $0.000000

 

    Deposit Taken

        Amount:      $20.000000

        New Balance: $20.000000

 

$

$ | Steve Withdraws Money

$ create event identity Banking_Application Account Withdrawal_submitted 4 10.00

 

    Withdrawal Accepted

        Amount:      $10.000000

        New Balance: $10.000000

 

$

$ | Steve Writes Check

$ create event identity Banking_Application Account Check_submitted 4 5.00

 

    Pay Cheque

        Amount:      $5.000000

        New Balance: $5.000000

 

$

$ | Sally Opens Account

$ create event creation Banking_Application Customer New_customer "Sally" "Texas" 100.00

 

    Customer Registered

        Full Name: Sally

        Address:   Texas

 

    Account Opened

        Account Number: 10000004

        New Balance:    $0.000000

 

    Deposit Taken

        Amount:      $100.000000

        New Balance: $100.000000

 

$

$ | Sally Writes Check

$ create event identity Banking_Application Account Check_submitted 5 20.00

 

    Pay Cheque

        Amount:      $20.000000

        New Balance: $80.000000

 

$

$ | Sally Makes Deposit

$ create event identity Banking_Application Account Make_deposit 5 20.00

 

    Deposit Taken

        Amount:      $20.000000

        New Balance: $100.000000

 

$

$ display entity Banking_Application Account

$

$ | Steve Writes Bouncing Check

$ create event identity Banking_Application Account Check_submitted 4 10.00

 

    Return Cheque

        Amount:                    $10.000000

        Charged Bounced Check Fee: $75.000000

        New Balance:               $-70.000000

 

$

$ display entity Banking_Application Account

$

$ | create event identity Banking_Application Account Account_ok 4

$

$ | Steve Attempts to Withdraw Money

$ create event identity Banking_Application Account Withdrawal_submitted 4 1000.00

 

$

$ | Sally Makes Deposit

$ create event identity Banking_Application Account Make_deposit 5 20.00

 

    Deposit Taken

        Amount:      $20.000000

        New Balance: $120.000000

 

$

$ | Steve Attempts to Write Check

$ create event identity Banking_Application Account Check_submitted 4 100.00

 

$

$ | Sally Makes Deposit

$ create event identity Banking_Application Account Make_deposit 5 20.00

 

    Deposit Taken

        Amount:      $20.000000

        New Balance: $140.000000

 

$

$ display entity Banking_Application Account

$

$ | Steve Attempts to Close Account

$ create event identity Banking_Application Account Close_account 4

 

$

$ | Sally Writes Check

$ create event identity Banking_Application Account Check_submitted 5 140.00

 

    Pay Cheque

        Amount:      $140.000000

        New Balance: $0.000000

 

$

$ | Sally Closes Account

$ create event identity Banking_Application Account Close_account 5

 

    Account Closed

        Account Number: 10000004

        Pay Out:        $0.000000

 

    Customer Leaves

        Full Name: Sally

 

$

$ | Steve Makes Deposit

$ create event identity Banking_Application Account Make_deposit 4 85.00

 

    Deposit Taken

        Amount:      $85.000000

        New Balance: $15.000000

 

$

$ | Steve Closes Account

$ create event identity Banking_Application Account Close_account 4

 

    Account Closed

        Account Number: 10000003

        Pay Out:        $15.000000

 

    Customer Leaves

        Full Name: Steve

 

$

$

$ host pause

Press any key to continue . . .

$

$ exit

 

        Model Simulation Elapsed Time: 00:00:01

 

    Disconnected from MATRIX*CORE on THU-02-JAN-2014 @ 11:38:10

Copyright © 2017 Dark Matter Systems Ltd. All Rights Reserved.