You are on page 1of 52

Module 3 – OBJECT ORIENTED MODELING

AND DESIGN

Name of Faculty: Manisha Kumari


Assistant professor
MCA Department
Contents
What is object orientation?
• What is oo development?
• Oo themes
• Evidence for usefulness of oo development
• Oo modeling history
• Modeling
• Abstraction
• The tree models
• Objects and class concepts
• Link and association concepts
• Generalization and inheritance
• A sample class model
• Navigation of class models
• Practical tip
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 2
Brindavan College, Bangalore
Introduction

Object-oriented modeling and design is a way of thinking


about problems using models organized around real world
concepts. The fundamental construct is the object, which
combines both data structure and behavior.

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 3
Brindavan College, Bangalore
OBJECT ORIENTATION?

OO means that we organize software as a collection of discrete


objects (that incorporate both data structure and behavior).
There are four aspects (characteristics) required by an OO
approach
 Identity.
 Classification.
 Inheritance.
 Polymorphism.

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 4
Brindavan College, Bangalore
Identity
• Identity means that data is quantized into discrete, distinguishable
entities called objects. E.g. for objects: personal computer, bicycle,
queen in chess etc.
• Objects can be concrete (such as a file in a file system) or
conceptual (such as scheduling policy in a multiprocessing OS).
Each object has its own inherent identity. (i.e. two objects are
distinct even if all their attribute values are identical).
• In programming languages, an object is referenced by a unique
handle.

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 5
Brindavan College, Bangalore
Inheritance
• It is the sharing of attributes and operations (features) among
classes based on a hierarchical relationship. A super class has
general information that sub classes refine and elaborate.
• E.g. Scrolling window and fixed window are sub classes of
window.

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 6
Brindavan College, Bangalore
Polymorphism
• Polymorphism means that the same operation may behave
differently for different classes.
• For E.g. move operation behaves differently for a pawn than for
the queen in a chess game

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 7
Brindavan College, Bangalore
OO DEVELOPMENT
• Development refers to the software life cycle: Analysis, Design and
Implementation.
• The essence of OO Development is the identification and
organization of application concepts, rather than their final
representation in a programming language.
• OO development is fundamentally a way of thinking and not a
programming technique.

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 8
Brindavan College, Bangalore
OO methodology

• System conception
• Analysis
• Domain Model
• Application Model
• System Design
• Class Design
• Implementation

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 9
Brindavan College, Bangalore
Three models
• Class Model - for the objects in the system & their relationships. It
describes the static structure of the objects in the system and their
relationship.
• State model - for the life history of objects. It describes the
aspects of an object that change over time. It specifies and
implements control with state diagrams-a graph whose nodes are
states and whose arcs are transition between states caused by
events.
• Interaction Model - for the interaction among objects. It describes
how the objects in the system co-operate to achieve broader
results. This model starts with use cases that are then elaborated
with sequence and activity diagrams.
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 10
Brindavan College, Bangalore
OO THEMES

1. Abstraction
2. Encapsulation (information hiding)
3. Combining data and behaviour
4. Sharing
5. Emphasis on the essence of an object
6. Synergy

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 11
Brindavan College, Bangalore
MODELLING AS A DESIGN
TECHNIQUE
• MODELLING
 Testing a physical entity before building it
 Communication with customers
 Visualization
 Reduction of complexity
• ABSTRACTION
 Abstraction is the selective examination of certain aspects of a
problem.
 The goal of abstraction is to isolate those aspects that are
important for some.

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 12
Brindavan College, Bangalore
3 models

Three kinds of models to describe a system


• Class model
• State model
• Interaction model

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 13
Brindavan College, Bangalore
Class model

• Describes basic structure of objects and their relationship


• Contains class diagram
• Class diagram is a graph whose nodes are object classes
(Classes) and whose arcs are relationships among classes

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 14
Brindavan College, Bangalore
State model

• Describes the aspects of a system that change over time.


• It specifies and implement control aspects of a system.
• Contains state diagram.
• State diagram is a graph whose nodes are states and whose arcs
are data-flows

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 15
Brindavan College, Bangalore
Interaction Model

• Describes how the objects in a system cooperate to achieve border


result
• Contains Use Case, Sequence diagram and activity diagram.
• Use case focuses on the functionality of a system –that is what a
system does for a user.
• Sequence diagram shows the object that interact and the time
sequence of their interaction.
• Activity diagram elaborate important processing steps

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 16
Brindavan College, Bangalore
Relationship among the Models
• Class model describes properties and behavior on which the
state and interaction model operate.
• State model shows decisions that depend on object value ,the
decisions causes changes in object value and subsequent
states.
• Interaction model provide overview of the operation of a
system.

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 17
Brindavan College, Bangalore
Object and Class concepts

Objects
Define objects as a concept, abstraction or thing with identity that
has meaning for an application.
All objects have identity and are distinguishable.eg:- Two apples can
be described as 2 different objects even though they have the same
descriptive properties.
Classes
An object class describes a group of objects with similar properties
(attributes), behavior (operations), relationships to other objects and
semantics.

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 18
Brindavan College, Bangalore
Class diagram:

It provides a graphical notation for modeling classes and their


relationship, thereby describing possible objects.
UML symbol for class is a box. List class name in boldface, center the
name in the box, and capitalize the first letter

Person Company

Class diagrams are useful both for abstract modeling and designing
actual program.

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 19
Brindavan College, Bangalore
Object diagram
• It shows individual objects and their relationship.
• A class diagram can have infinite set of object diagram.

JoeSmith:Person TCS:Company Apple: Fruit

• UML symbol for object is a box with an object name followed by a


colon and class name. the object and class name are both
underlined.

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 20
Brindavan College, Bangalore
Values and Attributes
• A Value is a piece of data.
• An attribute is a named property of a class that describes a value
held by each object of the class.
• Each attribute name is unique within a class.
• An attribute should be a pure data value, not an object.
Person JoeSmith:Person
name: string name: “JoeSmith”
age: integer age: 20
birthdate: date birthdate: 1 Jan 1993

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 21
Brindavan College, Bangalore
Links and Association Concepts

Link
• Links and associations are the means for establishing relationships
among objects.
• An association describes a group of links with common structure
and semantics.
Association
• Association is a group of links having common structure and
common behavior.
• Association depicts the relationship between objects of one or
more classes

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 22
Brindavan College, Bangalore
Degree of an Association

Degree of an association denotes the number of classes involved in a


connection. Degree may be unary, binary, or ternary.

• A unary relationship connects objects of the same class.


• A binary relationship connects objects of two classes.
• A ternary relationship connects objects of three or more classes.

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 23
Brindavan College, Bangalore
Cardinality Ratios of Associations

Cardinality of a binary association denotes the number of instances


participating in an association. There are three types of cardinality
ratios, namely −
• One–to–One − A single object of class A is associated with a single
object of class B.
• One–to–Many − A single object of class A is associated with many
objects of class B.
• Many–to–Many − An object of class A may be associated with
many objects of class B and conversely an object of class B may
be associated with many objects of class A.

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 24
Brindavan College, Bangalore
Multiplicity
• It specifies how many instances of one class may relate to a single
instance of an associated class.
• Multiplicity depends upon assumptions and how you define the
boundaries of a problem

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 25
Brindavan College, Bangalore
Generalization and Inheritance

• Generalization is a relationship between a super class and subclass.


• Each subclass is said to be inherit the features of its super class.

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 26
Brindavan College, Bangalore
Use of generalization

1. It support for polymorphism.


2. It structure the description of objects.
3. It enable reuse of code.

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 27
Brindavan College, Bangalore
Generalization and Specialization
Generalization and specialization represent a hierarchy of
relationships between classes, where subclasses inherit from super-
classes.
Generalization
• The common characteristics of classes are combined to form a
class in a higher level of hierarchy.
• It represents an “is – a – kind – of” relationship.
Specialization
• Specialization is the reverse process of generalization.
• The distinguishing features of groups of objects are used to form
specialized classes from existing classes.

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 28
Brindavan College, Bangalore
Continue…

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 29
Brindavan College, Bangalore
Class Diagram

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 30
Brindavan College, Bangalore
Activity
Draw a Class Diagram
1. Whatsapp Application
2. Atm machine
3. Facebook
4. Amazon online shopping app

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 31
Brindavan College, Bangalore
NAVIGATION OF CLASS MODELS
• Class models are useful for more than just data structure.
• Navigation of class model lets you express certain behavior.
• Navigation exercises a class model and uncovers hidden flaws
and omission, which you can then repair.

UML incorporates a language that can be used for navigation, the


object constraint language(OCL)

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 32
Brindavan College, Bangalore
Object constraint language(OCL).
OCL can traverse the constructs in class models
1. Attributes
2. Operations
3. Simple associations
4. Qualified associations
5. Associations classes
6. Generalization
7. Filters

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 33
Brindavan College, Bangalore
Write an OCL expression for –
1. What transactions occurred for a credit card account within a time
interval?
Soln: aCreditCardAccount.Statement.Transaction ->
select(aStartDate<=TransactionDateand
TransactionDate<=anEndDate)
2. What volumes of transactions were handled by an institution in the
last
year?
Soln: anInstitution.CreditCardAccount.Statement.Transaction ->
select(aStartDate<=TransactionDateandTransactionDate<=anEndDate).a
mount-
>sum( )
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 35
Brindavan College, Bangalore
Continue…
3. What customers patronized a merchant in the last year by any kind
of
credit card?
Soln: aMerchant.Purchase -> select(aStartDate<=TransactionDate
andtransactionDate<=anEndDate).Statement.CreditCardAccount.Maili
ngAddress.Cu
stomer ->asset( )
4. How many credit card accounts does a customer currently have?
Soln: aCustomer.MailingAddress.CreditCardAccount -> size( )

5. What is the total maximum credit for a customer for all accounts?
Soln: acustomer.MailingAddress.CreditCardAccount.Maximumcredit
Manisha Kumari -
Assistant Professor
> sum( )
Object oriented modeling and design PG Dept. MCA 36
Brindavan College, Bangalore
Advanced Class Modeling
• Advanced object and class concepts
• Association ends
• N-array association
• Aggregation
• Abstract classes
• Multiple inheritance
• Metadata
• Reification
• Constraints
• Derived data
• Packages Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 37
Brindavan College, Bangalore
Advanced object and class concepts
Enumerations
A data type is a description of values, includes numbers, strings,
enumerations
Enumerations: A Data type that has a finite set of values.
We can declare an enumeration by listing the keyword enumeration
in guillemets (<< >>) above the enumeration name in the top
section of a box. The second section
lists the enumeration values.
 Eg: Boolean type= { TRUE, FALSE}
 Eg: figure.pentype _____ - - - - - -------
 Two diml.filltype

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 38
Brindavan College, Bangalore
Continue…
Enumerations

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 39
Brindavan College, Bangalore
Multiplicity

• Multiplicity is a collection on the cardinality of a set, also


applied to attributes (database application).
• Multiplicity of an attribute specifies the number of possible
values for each instantiation of an attribute. i.e., whether an
attribute is mandatory ( [1] ) or an optional value ( [0..1] or * i.e.,
null value for database attributes ) .
• Multiplicity also indicates whether an attribute is single valued or
can be a collection.

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 40
Brindavan College, Bangalore
Scope

• Scope indicates if a feature applies to an object or a class.


• An underline distinguishes feature with class scope (static) from
those with object scope.
• Our convention is to list attributes and operations with class
scope at the top of the attribute and operation boxes, respectively.
• The most common use of class-scoped operations is to create
new instances of a class, sometimes for summary data as well

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 41
Brindavan College, Bangalore
Visibility

• Visibility refers to the ability of a method to reference a feature


from another class and has the possible values of public,
protected, private, and package.
• Any method can access public features.
• Only methods of the containing class and its descendants via
inheritance can access protected features.
• Only methods of the containing class can access private features.
• Methods of classes defined in the same package as the target
class can access package features

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 42
Brindavan College, Bangalore
Associations ends
• Association End is an end of association.
• A binary association has 2 ends; a ternary association has 3
ends.
• Association end name
• Multiplicity
• Ordering
• Bags and sequence
• Qualification
• Aggregation
• Changeability
• Navigability
• Visibility Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 43
Brindavan College, Bangalore
N-ary Association

• We may occasionally encounter n-ary


associations (association among 3 or more
classes). But we should try to avoid n-ary
associations- most of them can be
decomposed into binary associations, with
possible qualifiers and attributes.
Aggregation
• Aggregation is a strong form of association in
which an aggregate object is made of
constituent part.
• Aggregation is semantically an extended
object that is treated a as unit in many
operations.
• The most significant property of aggregation is
Transitivity and Antisymmetric.
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 45
Brindavan College, Bangalore
Continue…
• Aggregation versus Association
• Aggregation versus Composition
• Propagation of operations

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 46
Brindavan College, Bangalore
Abstract Classes
• An abstract class is a class that has no direct
instances but whose descendant classes have
direct instances.
• A concrete class is a class that can have direct
instances.

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 47
Brindavan College, Bangalore
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 48
Brindavan College, Bangalore
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 49
Brindavan College, Bangalore
Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 50
Brindavan College, Bangalore
Module 3
Draw Class Diagram for Super Market
Management System.

Manisha Kumari
Assistant Professor
Object oriented modeling and design PG Dept. MCA 51
Brindavan College, Bangalore
Exercise
1. What transactions occurred for a credit card
account within a time interval?
2. What volumes of transactions were handled by an
institution in the last year?
3. What customers patronized a merchant in the last
year by any kind of credit card?
4. How many credit card accounts does a customer
currently have?
5. What is the total maximum credit for a customer
for all accounts?

You might also like