Object-Oriented Analysis and Design


Apply Object-Oriented Method to system analysis and design

Object-Oriented analysis and design do not model a system by E-R diagram, and DFD diagram. These components are integrated in to objects. This can be inferred that an object contains data and processes/methods. Objects interact with each other through message to reach the common goal of a large system.
object-oriented analysis and design
         ATM object                                                              BankDatabase object

Object modeling offers a number of advantages for the system development.
  +Object modeling leads to an easy conversion of models (developed in analysis and design) to an implementation.
  +Objects can be reusable. They are easy to plug in the system.

Object structure

Since objects are important components in defining the structure of a system, you need to understand its structure or things that make up the object.  Objects contain data and processes that operate on the data.

object structure

For example, the Project object contains the following data and methods:
Data:
-ProNumber: p0012
-AssPers: Persons ref
-StartDate:09-02-2013
-Manager: Mr.A
-Tk: Tasks
-Budget: 20000
Methods:
-AddPer()
-DeletePer()
-SetTask()
-ChangeBud()

Objects Association and Containment

An object model usually contains many objects related to each other. There are two common ways that an object has relationships with other objects. The object can refer to another object. This relationship can be called object reference. Another type of relationship is that an object can contain many objects.

object relationship

-The ATM object has one-to-one relationship with the BankDatabase object.
-The ATM participates a composition relationship with a zero or one of object Withdrawal.
-The BackDatabase participates a composition relationship with zero or one of the Withdrawal object.
-The BankDatabase contains zero or more Account objects.

Objects Inheritance

An object can inherit features from another object. The derived object can have additional features or override features of the base object.

object inheritance

-Employee object has the following methods: SetDOB(), SetAdd(), SetPos(), SetSal(), GetDOB(), GetPos(), GetAdd(), GetSal(), and PrintInfo().
-Employee object inherits SetName(), SetSex(), GetName(), and GetSex() methods from Person object.
-Employee object overrides the Printinfo() method of the Person object to include additional information (DOB, Address, Position, and Salary) to print out.

Object-Oriented Analysis

After the software and users' requirements are collected, the most common diagram to be produced during system analysis using UML object-oriented method is USE CASE. USE CASE presents the activities (scenarios) of the users (actors) with the system.

Object-Oriented Analysis USE CASE


The picture above is an example of USE CASE. This USE CASE shows the interactions of the user (actor) with the ATM system. The activities of the user with the system can be account balance view, cash withdrawal, and funds deposit.
-In USE Case the human image Object-Oriented Analysis USE CASE represents the actor.


-Each use case is represented by oval symbol Object-Oriented Analysis USE CASE .

-The actors and activities in USE CASE diagram are collected from requirements document.

Object-Oriented Design

a). Defining classes
In the object-oriented method, the design tasks involve defining system structure/architecture and system behavior. System structure/architecture defines the system components that make up the system and their relationships. There are number of UML models that relate to the system structure. The most popular one covered in this tutorial is Class Diagram. Class Diagram specifies the structural components and their relationships in the system.

The structural components of the system are classes. Classes are templates to create objects.  You can define the classes by defining the things (nouns) from the requirements document. For example, things or nouns that can be collected from the ATM requirements document are ATM, account number, PIN code, transactions, balance enquiry, withdrawal, deposit, customer, user, bank database, screen, keypad, case dispenser, fund or money, deposit slot.
You also need to distinguish nouns that can be classes and attributes. A class in broader sense can be break down in to more specific classes. For example, transaction can be break in to balance enquiry, withdrawal, and deposit.

The nouns can be classes are ATM, Account, Balance Enquiry, Withdrawal, Deposit, Bank Database, Screen, Keypad, Case Dispenser, Deposit slot. The nouns can be attributes are account number, pin code, amount/fund, balance.

After classes are defined, their relationships are specified.
+Screen, Keypad, Case Dispenser, Deposit slot are in ATM class.
+ATM authenticates a user against the Bank Database.
+ATM executes account enquiry, withdrawal, or, deposit.
+Withdrawal modifies account balance through Bank Database.
+Back Database contains accounts.
+Balance enquiry requires screen to display the account balance.
+Withdrawal requires screen, and keypad to prompt for information and receive input, and cash dispenser to dispense cash to the user.
+Deposit also requires screen, and keypad to prompt for information and receive input, and deposit slot to receive envelope.

ATM system: Class Diagram
ATM class diagram
The Deposit class is not included in the Class Diagram because we want to keep the diagram simple and the
Deposit class is much like the Withdrawal.

b.) Defining attributes
Attributes describe the class. Each attribute can have a value. Attributes of class are implements as data
members in C++, C#, or Java. The table below shows the classes and their attributes.

Class Attributes
ATM Authenticated
BalanceEnquiry Account Number
Withdrawal Account Number, amount
Deposit Account Number, amount
BankDatabase  
Account Account number, Pin code, Available balance, total balance
Screen  
Keypad  
CashDispenser max number of bills/day
DepositSlot  
 

Then you will model attributes of classes as shown below:

modeling attributes


c.) Defining class operations
Classes/Objects perform operations. For example, ATM object executes balance enquiry, withdrawal, or deposit. You can identify the operations by collecting the verbs or verb phrases from the requirements document.
The table below shows operations that can be identified from the requirements document.
Class Operations
ATM Authenticate user
Execute transactions
BalanceEnquiry  
Withdrawal  
Deposit  
BankDatabase Retrieve account balance, debit amount from account,
, credit amount to account
Account  
Screen Display messages
Keypad Get user input
CashDispenser  
DepositSlot  
 
Then you will model operations of classes as shown below:

modeling operations

d). Defining system behavior

-State Machine Diagram describes the state changes of some components of the system to response to the
events occurring in the system. For example, the ATM object may change from not authenticated (initial
state) to authenticated when the user enters valid account number, and PIN code. When the user exits the
system, the stage changes from authenticated to not authenticated.
 
state machine diagram

-Activities Diagram describes the activities (and their order ) carried out by objects in the system.
Activity Diagram for Balance Enquiry
activity diagram

Activity Diagram for Withdrawal

activity diagram withdrawal

-Communication Diagram models the communications between objects in the system. An object communicates or interacts with another through messages. Messages in this context are the same as function calls in C++, or method invokes in C# or Java. The order or sequence in which the messages are sent to each other also specified in the diagram in numbers.

Object sends Messages To Object
ATM

displayMessage

getInput

authenticateUser

executeBalanceEnquiry

executeWithdrawal

executeDeposit

 

Screen

KeyPad

BankDatabase

BalanceEnquiry

Withdrawal

Deposit

 

BalanceEnquiry

getTotalBanace

getAvailableBalance

displayMessage

BankDatabase

BankDatabase

Screen

Withdrawal

displayMessage

getInput

getAvailableBalance

checkSufficient

debitAccount

dispenseCash

Screen

KeyPad

BankDatabase

CaseDespenser

BankDatabase

CashDispenser

Deposit

displayMessage

getInput

checkEnvelop

crediAccount

Screen

KeyPad

DepositSlot

BankDatabase

BankDatabase

validatePin

getTotalBalance

getAvailbleBalance

creditAccount

debitAccount

Account

Account

Account

Account

Account


Communication Diagram: communications between ATM, Screen, KeyPad, And BankDataBase objects.

commnunication diagram

Communication Diagram: communications between BalanceEnquiry, BankDataBase, and Screen objects to complete balance enquiry transaction.

commnunication diagram balance enquiry

-Sequence Diagram is another model to specify the communication between objects in the system. The Sequence Diagram focuses on the timing message flow rather than on the participants of the model.

sequence diagram

-A rectangle represents an object (e.g. BalanceEnquiry).
-A dot line drawn from the object is its lifeline that represents the time process.
-A solid arrow filled with arrow head extending from the sender’s activation to receiver ‘s activation is the message between the two objects in communication.
-An activation (thin vertical rectangle) happens a long the time progress of the object to indicate that the object is executing.

Object-Oriented Programming

In Object-Oriented Design tasks, classes, objects, data, processes, object states, and objects communication are modeled. Those models can be directly implemented by using a programming language that supports object-oriented programming method. This kind of programming language is called object-oriented programming. C++, Java, C#, Ruby, and Smalltalk are examples of popular object-oriented programming language today.

    Comments

    CAPTCHA image



    This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
    C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.