Вы находитесь на странице: 1из 21

OOPS CONCEPTS

Chapter-2/1
OBJECTIVE
Introduction to object-oriented systems development
SCOPE
Object-Oriented Notations
(a) Class Diagram
(b) Object Diagram
(c) Module Diagram
Steps of Object-Oriented Analysis (OOA)
Steps of Object-Oriented Design (OOD)
OOPS CONCEPTS
Chapter-2/2
OBJECT - ORIENTED NOTATIONS
NEED OF NOTATION
A diagram captures the details of a systems behavior.
A standard notation makes it possible for an analyst & developer to describe
& communicate decisions to others.
It is largely language-independent.
EXAMPLE
(a) The DFD drawn by the analyst can be easily understood by the programmer.
(b) If an architect in New Delhi city drafts the plan of a house, a builder in Bombay will
have no trouble understanding where to place doors, windows, and electrical outlets from the
details of the blueprints.
CLASS DIAGRAM
Used to show existence of classes & their relationships in the logical view of
a system.
A single class diagram represents a view of the class structure of a system.
Used in
(a) Analysis phase to indicate the roles & responsibilities of the entities.
(b) Design phase to capture the structure of the classes that form the
systems architecture.
OOPS CONCEPTS
Chapter-2/3
Elements of Class Diagram
Element ICON
Representation
Specification
Class The indent of this icon is to suggest
the boundaries of an abstraction, a
concept that does not necessary have
simple edges.
The dashed line indicates that clients
generally operate upon instances of a
class, not the class itself.
EXAMPLE
name
attribute
operations
PERSON
Name
Address
Jump( )
Walk( )
OOPS CONCEPTS
Chapter-2/4
Element ICON
Representation
Specification
Class
Relationships
(Association)
Used for connection between two classes.
Always labeled which denotes the nature
of relationship.
It is possible to have more than one
association between the same pair of
classes.
The number of links between each
instance of the source class & instances of
the target class are represented at the
target end.
EXAMPLE
There is an association between the
classes LibrarySystem & Supplier. Instances
of LibrarySystem define the consignment
that instances of the Supplier dispatch.
LibrarySystem
Books
CanBeIssued ( )
Defines
consignment
Supplier
OOPS CONCEPTS
Chapter-2/5
Element ICON
Representation
Specification
Class
Relationships
(Inheritance)
Used to denote is-a relationship.
Arrow head points to the base class.
Tail of the arrow points to the
derived class.
No cycles are allowed in the
inheritance relationship.
EXAMPLE
Class
Relationships
(part-of)
Filled circle appears at the end
denoting the aggregate class.
The class at the other end denotes
the part whose instances are contained
by the aggregate class object.
EXAMPLE
where FRUIT is a part-of TREE &
number of links are N
FRUIT TREE
MAMMALS
ANIMAL HUMAN
BEING
1 N
OOPS CONCEPTS
Chapter-2/6
Element ICON
Representation
Specification
Class
Relationship
(using)
Denotes the client / supplier
relationship.
Appears as an association with an
open circle at the end denoting the
client.
Used to indicate that operations of
the client class invoke operations of the
supplier class.
EXAMPLE
Class DisplaySection invokes ToDisplay &
ToStopDisplay functions depending upon the
output from the supplier class
LibraryCommittee.
LibraryCommittee
NameOfMember
Qualification
Display Section
ToDisplay( )
ToStopDisplay ( )
OOPS CONCEPTS
Chapter-2/7
EXPORT/ACCESS CONTROL
Access to the interface of a class can be
(a) Public : Accessible to all clients.
(b) Protected : Accessible to subclasses & class itself.
(c) Private : Accessible to the class itself.
The symbol is given at the source end of a relationship.
Access Control Symbol Example
Public No symbol
as it is the
default
access
The class Customer is a part of Class
HumanBeing.
Class HumanBeing contains public instance of
the class Customer.
CLASSROOM EXERCISE
State the problem indicated by the following class diagram
HumanBeing
Customer
1 1
DisplaySection
ToDisplay ( )
ToStopDisplay ( )
LibraryCommittee
NameOfMember
Qualification
LibrarySystem
Books
CanBeIssued( )
Supplier
Defines
Consignment
Bookseller
Dealer
Publisher
Customer
Define
Book
Requirement
Receives
Consignment
OOPS CONCEPTS
Chapter-2/8
Access Control Symbol Example
Protected
Class Animals is a base class of Elephant.
Class Elephant has a protected access control.
Private
The class VitaminContent is a part of Class
FoodItem.
Class FoodItem contains private instance of the
class VitaminContent.
HOME ASSIGNMENT
Specify the access control of the attributes of class Person
Person
Name
Age
Address
Elephant
Animals
FoodItem VitaminContent
1 1
OOPS CONCEPTS
Chapter-2/9
PHYSICAL CONTAINMENT
This is indicated in part-of relationship where one class (client) is a subset of
other class (server).
The specification of physical containment is necessary for meaningful code
generation from the design.
Indicated at the client end of the relationship.
In absence of physical containment, the classes can still have part-of
relationship.
Types of physical containment
Type Explanation Symbol Example
By value Denotes physical
containment of a value.
This containment ensures
that the lifetimes of the
source & client instances
remain equal.
Class State physically contain
N instances of class City.
By reference Denotes physical
containment of a pointer
or a reference.
This containment means
the two objects are
independent.
Classes Dealer & Publisher
are part-of class Supplier.
Class Supplier has only
references of class Dealer &
Publisher.
State
City
Supplier
Dealer
Publisher
OOPS CONCEPTS
Chapter-2/10
OBJECT DIAGRAM
Used to show existence of objects & their relationships in the logical view of
a system.
A single object diagram represents a view of the object structure of a system.
Used in
(a) Analysis phase to indicate the semantics of the systems behavior.
(b) Design phase to capture the semantics of mechanism in the logical
design of a system.
Elements of Object Diagram
Element ICON
Representation
Specification
Object
The name consists of Object Name :
Class Name. Object Name is optional.
The object icon without the object name
is said to be anonymous.
EXAMPLE
VIVEK is the
object name.
PERSON is the
class name.
name
attribute
VIVEK : PERSON
Name
Age
Address
OOPS CONCEPTS
Chapter-2/11
Element ICON
Representation
Specification
Object
Relationship
message
Two objects can be linked only if there
is a relationship between their respective
classes.
The communication between the two
objects consists of one object passing the
message to another.
The object sending the message is
known as client and the object which
provides services is known as supplier.
The messages are numbered so as to
indicate the relative ordering of
messages.
EXAMPLE
The object of class Supplier invokes the
function FindBook of object BPB ( class
Publisher ). This function will return the
availability of a particular Book for the
object of class Supplier .
: Supplier
HOME ASSIGNMENT
Draw the object diagram for the library system to determine the
availability of a specific book. Determine the traces of execution of
the system function.
BPB : Publisher
FindBook ( )
OOPS CONCEPTS
Chapter-2/12
MODULE DIAGRAM
Used to show the allocation of classes & objects to modules in the physical
design of a system.
A single module diagram represents a view of the module structure of a
system.
Used in development phase to indicate the physical architecture of the system.
Elements of Module Diagram
Element ICON
Representation
Specification
Module
name The name consists of Module Name
Each module consists of definition
of class & objects.
EXAMPLE
Module
Dependencies
The arrow head points to the
supplier module & the tail points to
the client module.
Dependency relationship is the only
link that exists between two modules.
EXAMPLE
Publisher : FindBook ( )
Publisher: FindBook ( )
Publisher :
AvailableInStore ( )
OOPS CONCEPTS
Chapter-2/13
Element ICON
Representation
Specification
Subsystems Each subsystem is a collection of
logically related modules.
Set of subsystems give the skeleton
of the physical model of a system.
EXAMPLE
name
CUSTOMER
LIBRARY SYSTEM
CLASSROOM EXERCISE
Draw the module diagram for an inventory system.
OOPS CONCEPTS
Chapter-2/14
OBJECT-ORIENTED ANALYSIS
OBJECT-ORIENTED ANALYSIS (OOA)
It is a method of analysis that examines requirements from the perspective of
the classes & objects found in the problem domain.
In this problem statement is divided into building blocks (objects) of the
software to be developed.
Steps involved in OOA
(a) Understanding the requirements of the user.
(b) Making the requirement specification of the software.
This involves identifying the outputs expected & inputs provided.
Expectations from the system are identified.
(c) Identifying the objects & its attributes.
(d) Specifying the interface provided by the object. Indicated with the help
of object diagram [without specifying the class of any object].
(e) Establishing the inter-connections between the objects in terms of
services.
(i) Similar type of objects are grouped together to form a class.
(ii) All objects in the object diagram are labeled with the names of
their corresponding class.
OOPS CONCEPTS
Chapter-2/15
EXAMPLE
PROBLEM STATEMENT - Automate Banking System.
REQUIREMENT STATEMENT (as given by the user)
The bank has number of accounts each having its own identity.
The accounts fall under three categories :
(a) Saving
(b) Current
(c) Fixed
Rate of interest varies with the type of accounts & time (in case of Fixed Account only).
The money can be deposited & withdrawn by the account holder provided a minimum
balance is maintained.
At the end of the month bank statement is generated.
OBJECTS OF THE SYSTEM
(a) AccountNo123
(b) AccountHolderAnu
ATTRIBUTES OF THE OBJECTS
AccountNo123
AccountNumber
TypeOfAccount
BalanceAmount
TimeOfFixedAmount
AccountHolderAnu
AccountNumber
Name
Age
Address
Phone
Occupation
OBJECT INTERFACE
AccountNo
123
AcountHolderAnu
FindAccount ( )
OOPS CONCEPTS
Chapter-2/16
GROUPING OBJECTS INTO CLASS
Since the objects are of different types so they cannot be grouped.
There will be two classes - Account & AccountHolder for objects AccountNo123 &
AccountHolderAnu respectively.
OOPS CONCEPTS
Chapter-2/17
OBJECT-ORIENTED DESIGN
OBJECT-ORIENTED DESIGN (OOD)
A method of design which uses a notation for depicting both logical &
physical models of the system under design
It is concerned with the mapping of objects identified with the objects in the
problem domain.
Steps involved in OOD
(a) Reviewing the objects created in the analysis phase.
(b) Identifying the class dependencies. This deals with the type of
relationships (is-a, part-of, physical containment, using)
(c) Building the class hierarchies.
(d) Designing the member functions of each class.
(e) Designing the driver program. Driver program
(i) Monitors the working of the software.
(ii) Is used to build an interface between the user & the software.
(iii) Creates objects from the class definitions.
(iv) Arranges communication between objects.
OOPS CONCEPTS
Chapter-2/18
EXAMPLE
CLASS DEPENDENCIES & CLASS HIERARCHIES
Class AccountHolder can be a part-of class Person ( Created in the previous session ).
Class Account is an independent class.
MEMBER FUNCTIONS OF EACH CLASS
CLASS : AccountHolder
Member Functions:
AddAccountHolder ( )
DeleteAccountHolder ( )
ModifyAttributes ( )
AcceptAccountNo ( )
FindAccount ( )
CLASS : Account
Member Functions:
AddAccount ( )
DeleteAccount ( )
ViewAccount ( )
WithdrawMoney ( )
DepositMoney ( )
CalculateInterest ( )
PrintBankStatement ( )
Person AccountHolder
Account
OOPS CONCEPTS
Chapter-2/19
DESIGNING THE DRIVER PROGRAM
The driver program needs to do -
Create objects of classes Account & AccountHolder.
Display the menu specifying the services available. Services are
(a) Adding New Account Holders
(b) Deleting the existing Account of an Account Holder
(c) Modifying Details of an Account Holder
(d) Find the balance of an Account
(e) Withdraw Money
(f) Deposit Money
(g) Calculate Interest
(h) Print Bank Statement
OOPS CONCEPTS
Chapter-2/20
HOME ASSIGNMENT
Identify the classes & their relationships for the following case
study :
FORD TRACTORS LTD. want to computerize their Goods Receiving &
Stocking System. The present manual system involves :
The guard at the factory gate receives the goods & the dispatch note
sent by the vendor of the company. The guard makes an entry in the
goods receive register which has columns for Vendor_Code,
Invoice_Number, Purchase_order_no , Item & Qty_Received.
After making the entry the goods are passed on to the Clerk who
verifies the number of items received against the purchase order that was
sent to the vendor. An entry is made in the register.
The goods are passed to the Quality Control Inspector. The Inspector
checks the goods for quality standards & prepares a list of items which
have passed the test. This list is given to the Clerk , who makes the
debit note & updates the goods register accordingly.
CLASSROOM EXERCISE
A school library needs to be automated. Identify the classes & their
relationships. Outline the responsibilities of each class.
Details
The library has a number of books each having unique identity.
The books have two categories - For Issue & Not for Issue
Library maintains information of library staff & library members
Every month end new purchases are made.
OOPS CONCEPTS
Chapter-2/21
SUMMARY
Key points covered in this session
A diagram captures the concept of a design.
There are three basic diagrams used for object-oriented development life cycle.
(a) Class Diagram used to specify the existence of classes & their
relationship.
(b) Object Diagram used to specify the existence of objects & their
relationship.
(c) Module Diagram used to specify the module architecture of system.
Object-oriented Analysis is a method of analysis used to identify the system
requirements in terms of objects & their interactions.
Object-oriented Design is a method of design used to identify the system
requirements in terms of classes, class hierarchies & their interrelationships.