Reusable Object-Oriented Patterns in Banking Applications
Reusable Object-Oriented Patterns in Banking Applications
ABSTRACT
INTRODUCTION
Early in the 1990s many software engineers were seeking ways in which
design knowledge could be represented and shared between practitioners
[11]. This led to an interest in the works of Christopher Alexander and
resulted in early workshops on Object-Oriented Programming, Systems,
Languages and Applications (OOPSLA ) [12, 13]. Christopher Alexander, an
architect, along with his colleagues originally developed the pattern
concept as a theoretical account of the properties of a human or ‘living’,
built environment [10]. Discussed at these workshops are patterns that
address many topics including the organisation of software projects and
teams, design of user interaction, and software architectural design. The
approach to patterns adopted in these software engineering efforts have
significantly improved on Alexander’s original work.
Perhaps the best known work associated with these series of workshops
and conferences is Gamma et al.’s book ‘Design Patterns: Elements of
Reusable Object Oriented Software’ [6]. Gamma et al. state that a pattern
has four essential elements, a pattern name, the description of a problem,
a solution and a discussion of the consequences, i.e. costs and benefits, of
applying the pattern. Examples of object-oriented design patterns include
‘Observer’ (a generalisation of the familiar ‘model-view-controller’
architecture for user interface construction), and ‘Command’ (a software
design to implement undoability). Although Gamma et al.’s patterns do
contain cross references to each other; the patterns do not form a
generative language. Rather, the authors refer to their collection as a
“catalog”. Coplien & Schmidt [14] discusses the differences between
pattern languages and pattern catalogues in software engineering.
2
is to construct and document design patterns that will be useful in
architecting banking applications aimed at automating banking operations.
To achieve this aim, our objectives include the following among others:
Creational Patterns
Abstract Factory Creates an instance of several families of classes
Builder Separates object construction from its representation
Factory Method Creates an instance of several derived classes
Prototype A fully initialized instance to be copied or cloned
Singleton A class of which only a single instance can exist
Structural Patterns
3
Adapter Match interfaces of different classes
Bridge Separates an object’s interface from its implementation
Composite A tree structure of simple and composite objects
Decorator Add responsibilities to objects dynamically
Facade A single class that represents an entire subsystem
Flyweight A fine-grained instance used for efficient sharing
Proxy An object representing another object
Behavioural Patterns
Chain of Resp. A way of passing a request between a chain of objects
Command Encapsulate a command request as an object
Interpreter A way to include language elements in a program
Iterator Sequentially access the elements of a collection
Mediator Defines simplified communication between classes
Memento Capture and restore an object's internal state
Observer A way of notifying change to a number of classes
State Alter an object's behavior when its state changes
Strategy Encapsulates an algorithm inside a class
Template Method Defer the exact steps of an algorithm to a subclass
Visitor Defines a new operation to a class without change
4
Participants: The classes and/or objects participating in this pattern are:
Proxy (MathProxy)
• maintains a reference that lets the proxy access the real subject.
Proxy may refer to a Subject if the RealSubject and Subject
interfaces are the same.
• provides an interface identical to Subject's so that a proxy can be
substituted for for the real subject.
• controls access to the real subject and may be responsible for
creating and deleting it.
• other responsibilites depend on the kind of proxy:
remote proxies are responsible for encoding a request and its
arguments and for sending the encoded request to the real
subject in a different address space.
virtual proxies may cache additional information about the real
subject so that they can postpone accessing it. For example,
the ImageProxy from the Motivation caches the real images's
extent.
protection proxies check that the caller has the access
permissions required to perform a request.
Subject (IMath)
• defines the common interface for RealSubject and Proxy so that a
Proxy can be used anywhere a RealSubject is expected.
RealSubject (Math)
• defines the real object that the proxy represents.
Sample code in C#
This structural code demonstrates the Proxy pattern which provides a
representative object (proxy) that controls access to another similar object.
5
// Proxy pattern -- Structural example
using System;
namespace DoFactory.GangOfFour.Proxy.Structural
{
class MainApp
{
static void Main()
{
// Create proxy and request a service
Proxy proxy = new Proxy();
proxy.Request();
// "Subject"
// "RealSubject"
// "Proxy"
realSubject.Request();
}
}
}
Output
6
Called RealSubject.Request()
This real-world code demonstrates the Proxy pattern for a Math object represented by a
MathProxy object.
namespace DoFactory.GangOfFour.Proxy.RealWorld
{
class MainApp
{
static void Main()
{
// Create math proxy
MathProxy p = new MathProxy();
// Do the math
Console.WriteLine("4 + 2 = " + p.Add(4, 2));
Console.WriteLine("4 - 2 = " + p.Sub(4, 2));
Console.WriteLine("4 * 2 = " + p.Mul(4, 2));
Console.WriteLine("4 / 2 = " + p.Div(4, 2));
// "Subject"
// "RealSubject"
// "Proxy Object"
public MathProxy()
7
{
math = new Math();
}
4 +2=6
4 -2=2
4 *2=8
4 /2=2
Accountability Patterns
Party Captures the notion of the entity, person or organisation
Organisation Hierarchy Defines a hierarchy of operational units within an organisation
Defines responsibility relationships within the organizational
Accountability
hierarchy
1
Slightly modified to reflect author’s perspective
8
Inventory and Accounting Patterns
Records the current value of an entity as well as the history of
Account changes that affect its value by entries made. We differentiate
between internal and customer accounts
Defines the structure of internal and customer accounts,
Chart of accounts2
include items like totaling levels
Links an entry in one account to a corresponding but opposite
Transaction
entry in another account
Groups balances in a set of accounts as entries in another
Summary Account
account. Also referred to as interface account
Used to record entries that are purely for record and
Memo Account
documentation purposes
Posting Rule Defines rules that are used to make (post) entries into accounts
A set of related accounts in terms of attributes such as interest
Product3
rates, charges applicable, interface (summary) account, etc
Balance Sheet and Defines the networth of a person or organization by
Income Statement considering his assets against his liabilities
Trading Patterns
Represents the simplest financial deal, namely, buying some
Contract
instrument from another party
Considers contracts collectively for the purpose of risk
Portfolio
management
Expresses the price of an item traded in the financial market as
Quote two numbers; the price to buy (which is the bid) and the price
to sell (the offer)
Shows how prices change over time and keeps a history of
Scenario
those changes
2
Included by author
3
included by author
9
This classification is not exhaustive. Secondly, it is not universal as banking
practices are highly influenced by local laws and regulatory guidelines. We
intend to examine the concepts and suggest a classification and design
patterns that take the Nigeria context of banking into consideration but still
complying with international standards. This helps us quickly come up with
a framework that is well-known and can be easily customized for banking
application development for any environment.
This general form for documenting patterns has been modified by several
authors to suit their purposes. Whatever the variations, the documentation
for a design pattern should contain enough information about the problem
that the pattern addresses, the context in which it is used, and the
suggested solution. That is, the layouts used to document design patterns,
must usually resemble the essential parts. The authors usually include
additional sections to provide more information, and organize the essential
parts in different sections, possibly with different names.
A commonly used format is the one used by the Gang of Four [6]. It
contains the following sections for describing a pattern:
10
Intent: This section should describe the goal behind the pattern and the
reason for using it. It resembles the problem part of the pattern. A short
statement that answers the following questions: What does the design
pattern do? What is its rationale and intent? What particular design issue or
problem does it address?
Also Known As: A pattern could have more than one name. These names
should be documented in this section.
Consequences: This section describes the results, side effects, and trade
offs caused by using a pattern. How does the pattern support its
objectives? What are the trade-offs and results of using the pattern? What
aspect of system structure does it let you vary independently?
11
Sample Code: An illustration of how this pattern can be used in a
programming language code fragment that illustrates how you might
implement the pattern in a language of your choice.
Related Patterns: This section includes other patterns that have some
relation with this pattern, so that they can be used along with this pattern,
or instead of this pattern. It also includes the differences this pattern has
with similar patterns. What design patterns are closely related to this one?
What are the important differences? With which other patterns should this
one be used?
RESEARCH METHODOLOGY
12
model, each class in the design model traces to a corresponding class in
the domain model. There can be one-to-one, one-to-many, and many-to-
many relationships between design classes and domain classes. Because it
should be possible to implement a domain model in more than one way,
the direction of this class tracing should normally be only from the design
model to the domain model.
13
Retail Channel - Teller
«uses» «uses»
«uses»
Customer Accounts
«extends»
«extends» «uses»
Creates accounts
«extends»
Record Transactions
GL Accounts
SIGNIFICANCE OF STUDY
In Nigeria today so much of our hard-earned foreign exchange is spent
purchasing foreign software. In the banking sector, this situation is most
acute as it costs an average of $4million (Four million US dollars) to license
a banking application. It costs a bank an average of $300,000 (three
hundred thousand US dollars) for annual maintenance fees*. This situation
has subsisted because of the lack of indigenous efforts to develop banking
*
Sourced from subject matter experts
14
applications that will meet the stringent requirements of the regulatory
authorities as well as the operational complexities of banking operations.
This is large due to the lack of appropriate development practice that will
guarantee quality product considering how large and complex banking
applications are. Against this background, the significance of this study can
be summarized as follows:
• Primarily, we intend to extend and customize existing classification of
banking patterns [4] and make them reusable within the context of
banking application development for the Nigerian market and beyond
• Introduce software design patterns as a tool for introducing
consistency to the banking application software development process
as well as enable the reuse of banking software artifacts.
• Construct banking applications design patterns that take the specific
regulatory requirements of the Nigerian banking industry into
consideration
• This study is also expected to make inroads into other areas of
software development where the Nigerian practice is seriously lacking
behind. In particular, our framework for the banking application
should find application in the general financial services industry and
beyond.
• The high cost of developing a banking application has fundamentally
discouraged local efforts at developing one. Our results are expected
to form a knowledge base of software artifacts that can be reused by
developers thereby reducing cost of development and increasing
speed to market. It will become a basis for banking application
developers to share their design and be able to improve on the
patterns.
• Having access to a collection of patterns related to the banking
domain makes the development of banking applications more
efficient and helps us address the problem of banking application
development efforts failing after so much have been invested[4].
• Adopting the documentation format of the Gang of Four, we shall be
improving on earlier documentations of design patterns in the
banking and general financial domain.
CONCLUSION
15