1
Module-3
Object Oriented Design Techniques/Methods
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Content of Module -3 2
What is object orientation? What is OO development? OO themes; Evidence for usefulness of
OO development; OO modelling history, modeling as design Technique: Modelling; abstraction;
the three models. Object and class concepts; Link and associations concepts; Generalization and
inheritance; A sample class model; Navigation of class models; Practical tips.
Advanced objects and class concepts; Associations ends; N-array association; Aggregation,
Abstract class; Multiple inheritance; Metadata; Reification; Constraints; Derived data; packages;
practical tips.
Text Book Title and Authors Chapters Number
Object-Oriented Modeling and Design with UML, 1,2,3,4 and Page numbers: 1 to 83
2nd Edition, Michael Blaha and James Rumbaugh
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Evolution of Software Development Modeling 3
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Introduction 4
Object-Oriented Programming (OOP) is the term used to describe a programming
approach based on objects and classes. The object-oriented paradigm allows us
to organise software as a collection of objects that consist of both data and
behaviour. This is in contrast to conventional functional programming practice that
only loosely connects data and behaviour.
The object-oriented programming approach encourages:
•Modularisation: where the application can be decomposed into
modules.
•Software re-use: where an application can be composed from
existing and new modules.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
5
Object-oriented
modeling is
frequently
accomplished using
the
Unified Modeling
Language (UML)
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
What is UML? 6
• UML stands for “Unified Modeling Language”
• It is a industry-standard graphical language for specifying,
visualizing, constructing, and documenting the artifacts of software
systems
• The UML uses mostly graphical notations to express the OO analysis
and design of software projects.
• Simplifies the complex process of software design
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Why UML for Modeling? 7
• Use graphical notation to communicate more clearly than natural
language (imprecise) and code(too detailed).
• Help acquire an overall view of a system.
• UML is not dependent on any one language or technology.
• UML moves us from fragmentation to standardization.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Types of UML Diagrams/Components 8
• Use Case Diagram
• Class Diagram
• Sequence Diagram
• Collaboration Diagram
• State Diagram
This is only a subset of diagrams … but are most widely used
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
What is Object-Orientation? 9
Object Oriented(OO): Software is organized as a collection of discrete objects
that incorporate both data structure and behavior.
▪ The focus of procedural programming is to break down a programming task
into a collection of variables, data structures, and subroutines, whereas in
object-oriented programming it is to break down a programming task
into objects that expose behavior (methods) and data (fields) using interfaces.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Object-Oriented Design 10
Object-oriented design is a method
of design encompassing the process
of object- oriented decomposition
and a notation for depicting both
logical and physical as well as
static and dynamic models of the
system under design.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Benefits of Object-Oriented Modeling 11
▪ Ability to tackle challenging problems
▪ Improved communication between users, analysts, designer, and
programmers
▪ Increased consistency in analysis and design
▪ Explicit representation of commonality among system components
▪ System robustness
▪ Reusability of analysis, design, and programming results
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
OO Approach 12
OO approach
generally include
four aspects:
Identity means that data is quantized into discrete, distinguishable entities
identity, called objects
classification, Classification means that objects with the same data structure ( attributes)
and behavior ( operations) are grouped into a class.
inheritance, Inheritance is the sharing of attributes and operations ( features) among
classes based on a hierarchical relationship.
polymorphism. Polymorphism means that the same operation may behave differently for
different classes.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
13
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
What is OO Development? 14
Object Oriented Development (OOD)
has been touted as the next great
advance in software engineering. It
promises to reduce development time,
reduce the time and resources required to
maintain existing applications, increase
code reuse, and provide a competitive
advantage to organizations that use it.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
What Is OO Development? 15
OO Technology Process Perspective
Analyze (use case) first, then design,
OO Analysis then program
OO Design design then program
OO Prog. Languages just program!
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
OO Themes 16
Four Pillars of Object Oriented Programme/Design
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
OO Themes 17
Abstraction Classes and instances Encapsulation
Abstraction consists Objects are instances of classes. A Encapsulation (also information hiding) consists of
of focusing on the class is a definitive Description of a separating the external aspects of an object, which
essential, inherent group of objects with similar are accessible to other objects, from the internal
aspects of an entity properties and behaviors. Classes are details of the object, which are hidden from other
and ignoring its abstract, objects are concrete. Objects objects.
accidental aspects. are aware of their class identity. •Objects have an outside (how they are seen or
interact) and an inside (what they are.)
Polymorphism
Inheritance
•Polymorphism is the kindred to the incorporation of data and
behavior. From the outside, the same operation Solve or Draw Inheritance is a mechanism
applies to various objects (solvable or, respectively, for sharing similarities among
drawable). The object user is not burdened with the classes while preserving their
implementation - the inside - of the object. The object knows differences
how to do the job.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Components of Object Oriented Programme/Design 18
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Evidence for usefulness of OOD 19
• Applications at General Electric Research and Development Center.(1990)
• OO techniques for developing compilers, graphics, user interfaces, databases ,an OO
language, etc.
• OO technology is a part of the computer science and software engineering
mainstream.
• Important forums: (OOPSLA,ECOOP) Object Oriented Programming Systems,
Languages and Applications. European Conference on OOP.
• IEEE Computer and Communications of the ACM.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
OO Modeling History 20
▪ OMT – introduced in 1991
▪ Popularity of OO modeling led to a new Problem – Plethora of alternative notations, - similar idea - Different Symbols
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
21
Flipped Class Learning
Module-2 –Requirement Engineering
Self Assessment test
https://forms.gle/pr8DLWavGE9qGiQb7
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
22
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
23
Modeling as Design Technique
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Modeling 24
Models are forms of description often adopted
in software development. They are abstractions used to
represent and communicate what is important, devoid of
unnecessary detail, and to help developers deal with the
complexity of the problem being investigated or the solution
being developed.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Abstraction 25
Abstraction is the concept of object-oriented programming that "shows" only
essential attributes and "hides" unnecessary information. The main purpose
of abstraction is hiding the unnecessary details from the users. ... It is one of the most
important concepts of OOPs.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Three Models 26
There are 3 types of models in the object oriented modeling and
design are: Interaction model
The interaction model describes how
Class model State model the objects in a system cooperate to
achieve broader results. The
The class model describes the The state model describes the interaction model starts with use
static structure of the objects in a aspects of an object that cases that are then elaborated with
system and their relationships. The change over time. The state sequence and activity diagrams.
class model defines the context for model specifies and implements
software development—the control with state diagrams. ▪ A use case focuses on the
universe of discourse. The class functionality of a system—that is,
model contains class diagrams. A state diagram is a graph what a system does for users.
whose nodes are states and ▪ A sequence diagram shows the
A class diagram is a graph whose whose arcs are transitions objects that interact and the time
nodes are classes and whose arcs between states caused by sequence of their interactions.
are relationships among classes. events. ▪ An activity diagram elaborates
important processing steps.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Classes and Objects 27
• Class: An entity that has a well-defined role in the application domain, as well
as state, behavior, and identity
– Tangible: person, place or thing
– Concept or Event: department, performance, marriage, registration
– Artifact of the Design Process: user interface, controller, scheduler
• Object: a particular instance of a class
Objects exhibit BEHAVIOR as well as attributes
➔ Different from entities
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
State, Behavior, Identity 28
• State: attribute types and values
• Behavior: how an object acts and reacts
– Behavior is expressed through operations that can be performed on it
• Identity: every object has a unique identity, even if all of its attribute values
are the same
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Objects 29
Objects lie at the heart of object-oriented technology
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Objects and classes 30
Each class describes a
possibly infinite
set of individual objects.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Objects and classes 31
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Classes 32
Objects with the same
attributes and behaviour
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Use-Case Diagrams 33
• A use-case diagram is a set of use cases
• A use case is a model of the interaction between
➢ External users of a software product (actors) and
➢ The software product itself
➢ More precisely, an actor is a user playing a specific role
• describing a set of user scenarios
• capturing user requirements
• contract between end user and software developers
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Use-Case Diagrams 34
• Actors: A role that a user plays with respect to the system, including human users and
other systems. e.g., inanimate physical objects (e.g. robot); an external system that needs
some information from the current system.
• Use case: A set of scenarios that describing an interaction between a user and a system,
including alternatives.
• System boundary: rectangle diagram representing the boundary between the actors
and the system.
Boundary
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Use-Case Diagrams 35
• Association:
communication between an actor and a use case; Represented by a solid line.
• Generalization: relationship between one general use case and a special use
case (used for defining special alternatives) Represented by a line with a
triangular arrow head toward the parent use case.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Use-Case Diagrams 36
Include: a dotted line labeled <<include>> beginning at base use case and ending
with an arrows pointing to the include use case. The include relationship occurs when a
chunk of behavior is similar across more than one use case. Use “include” in stead of
copying the description of that behavior.
<<include>>
Extend: a dotted line labeled <<extend>> with an arrow toward the base case. The
extending use case may add behavior to the base use case. The base class declares
“extension points”.
<<extend>>
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Use-Case Diagrams 37
Boundary Use Case
Actor
Library System
Borrow Employee
Client
Order Title
Fine Remittance
Supervisor
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Use-Case Diagrams 38
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Use-Case Diagrams 39
• Both Make Appointment
and Request Medication
include Check Patient
Record as a subtask (include)
• The extension point is
written inside the base case
Pay bill; the extending class
Defer payment adds the
behavior of this extension
point. (extend)
• Pay Bill is a parent use case
and Bill Insurance is the
child use case.
(generalization)
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Class diagram 40
• A class diagram depicts classes and their interrelationships
• Used for describing structure and behavior in the use cases
• Provide a conceptual model of the system in terms of entities and their
relationships
• Used for requirement capture, end-user interaction
• Detailed class diagrams are used for developers
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Class diagram 41
• Each class is represented by a rectangle subdivided Name
into three compartments Account_Name
❑ Name - Customer_Name
❑ Attributes Attributes
❑ Operations
- Balance
+addFunds( ) Operations
• Modifiers are used to indicate visibility of attributes
and operations. +withDraw( )
❑ ‘+’ is used to denote Public visibility (everyone) +transfer( )
❑ ‘#’ is used to denote Protected visibility (friends and
derived)
❑ ‘-’ is used to denote Private visibility (no one)
• By default, attributes are hidden and operations are
visible.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Class and object diagram 42
Class diagram showing two classes
Object diagram with two instances
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Operations 43
• A function or service that is provided by all instances of a class
• Types of operators:
– Constructor: creates a new instance of a class
– Query: accesses the state of an object but does not alter its state
– Update: alters the state of an object
– Scope: operation applying to the class instead of an instance
Operations implement the object’s behavior
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
OOD and EER 44
OOD- Object Oriented Design EER-Extended Entity-Relationship
Class Entity type
Object Entity instance
Association Relationship
Inheritance of attributes Inheritance of attributes
Inheritance of behavior No representation of behavior
enhanced entity–relationship
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Link and association 45
Link and Association in UML
represent
the relation between
objects and classes.
Link is used to establish
the relation between the
objects in the object
diagram.
Association is used to
represent the relation
between the classes.
Many-to-many association. An association describes a set of potential
links in the same way that a class describes a set of potential objects.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Associations 46
• Association:
– Relationship among object classes
• Association Role:
– Role of an object in an association
– The end of an association where it connects to a class
• Multiplicity:
– How many objects participate in an association. Lower-bound. Upper
bound (cardinality).
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Association relationships of different degrees 47
Unary
Lower-bound – Upper-bound
Represented as: 0..1, 0..*, 1..1, 1..*
Binary Similar to minimum/maximum cardinality rules in EER
Ternary
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Values and Attributes 48
A Value is a piece of An Attribute is a
data. You can find named property of a
values by examining class that describes a
problem value held by each
documentation for object
examples. of the class.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Operations and Methods 49
An Operation is a function Method is
or procedure that may be the implementation of
applied to or by objects in a an operation for a
class class.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Multiplicity 50
Multiplicity specifies the
number of instances of one
class that may relate to
a single instance of an associated
class.
Multiplicity constrains the number
of related objects.
Many-to-many association. An association describes a set of potential
links in the same way that a class describes a set of potential objects.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Multiplicity.. 51
Multiplicity specifies the
number of instances of one
class that may relate to
a single instance of an associated
class.
Multiplicity constrains the number
of related objects.
One-to-one association. Multiplicity specifies the number of
instances of one class that may relate to a single instance of an
associated class.
Zero-or-one multiplicity. It may be
optional whether an object is involved
in an association.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Multiplicity… 52
Multiplicity specifies the
number of instances of one
class that may relate to
a single instance of an associated
class. Association vs. link. A pair of objects can be instantiated at
Multiplicity constrains the number most once per association (except for bags and sequences).
of related objects.
if
you want two
links between the
same objects,
you must have Association vs. link. You can use multiple associations to model
multiple links between the same objects.
two associations.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Association End Names 53
The notion of an association end is an
important concept in the UML.
You can not only assign a multiplicity to an
association end, but you can give it a
name as well.
Association end names often appear as
nouns in problem descriptions. Association end names. Each end of an
association can have a name.
Association end names. Association end names
Association end names.Use association
are necessary for associations between two
objects of the same class. They can also distinguish
end names to model multiple references
multiple associations between a pair of classes. to the same class.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Ordering 54
The ordering is an inherent part of the
association. You can indicate an ordered set of objects by writing
“{ordered}” next to the appropriate association end.
Ordering the objects for an association end. Ordering sometimes occurs for “many”
multiplicity.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Bags and Sequences 55
A bag is a collection of elements with duplicates allowed.
A sequence is an ordered collection of elements with duplicates allowed.
Like the {ordered} indication,
{bag} and {sequence} are permitted only for binary associations
An example of a sequence. An itinerary may visit multiple
airports, so you should use {sequence} and not {ordered}.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Association Classes 56
▪ An association class is an
association that is also a class.
▪ Like the links of an association,
the instances of an association
class derive identity from instances
of the constituent classes. An association class. The links of an
▪ Like a class, an association class association can have attributes.
can have attributes and operations
and participate in associations.
▪ We can find association classes by
looking for adverbs in a problem
statement or by abstracting known
values.
Association classes. Attributes may also occur for
one-to-many and one-to-one associations.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Association Classes.. 57
Association class vs. ordinary class. An association class is
Proper use of association classes. Do not fold much different than an ordinary class.
attributes of an association into a class.
An association class participating in an
association. Association classes let you
specify identity and navigation paths
precisely.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Qualified Associations 58
A qualified association is an
association in which an attribute Qualified association. Qualification increases the precision of a
called the qualifier disambiguates the model.
objects for a “many” association end.
It is possible to define qualifiers for
one-to- many and many-to-many
associations.
Qualified association. Qualification also facilitates
traversal of class models.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Generalization and Inheritance 59
Generalization: It is also referred as “is-a”
relationship. It is relationship between a class
(super class) and one or more variations of the
class (sub classes).
It organizes classes by their similarities and
differences, structuring the description of objects.
The super class holds common attributes, operations
and association.
The subclasses add specific attributes, operations
and associations. Notation: A large hollow arrowhead is used to show
Each sub class inherits the features of its super generalization. The arrowhead points towards the
super class.
class.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Generalization and Inheritance.. 60
Inheritance: It is the mechanism of
inheriting features of super class in its
subclass. Inheritance provides
reusability of code where code
declared for super class can be used
by its sub class.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Generalization and Specification 61
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Generalization and Specification 62
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Generalization and Inheritance-Example 63
A multilevel inheritance hierarchy with
instances. Generalization
organizes classes by their similarities and
differences, structuring the
description of objects.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Generalization and Inheritance-Example 64
Inheritance for graphic figures. Each
subclass inherits the
attributes, operations, and associations
of its super classes.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Use of Generalization 65
Generalization has three purposes
1. One of which is support for polymorphism
2. Second purpose of generalization is to structure the description of objects.
3. Third purpose is to enable reuse of code—you can inherit code within your
application as well as from past work (such as a class library).
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Generalization, Specialization, and Inheritance 66
The word generalization derives from the fact that the superclass generalizes
the subclasses.
Specialization refers to the fact that the subclasses refine or specialize the
superclass.
Inheritance is the mechanism for sharing attributes, operations, and associations
via the generalization/specialization relationship.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
A Sample Class Model 67
Class model of a windowing system
a class model of a workstation window
management system
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Navigation of Class Models 68
Scenario/Tasks: An institution may issue many credit card accounts, each identified by
an account number. Each account has a maximum credit limit, a current balance, and a
mailing address. The account serves one or more customers who reside at the mailing
address. The institution periodically issues a statement for each account. The statement
lists a payment due date, finance charge, and minimum payment. The statement
itemizes various transactions that have occurred throughout the billing interval: cash
advances, interest charges, purchases, fees, and adjustments to the account. The name
of the merchant is printed for each purchase.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Navigation of Class Models 69
Simple Model for Credit Card Accounts.
▪ An institution may issue many credit card accounts, each identified by an account number.
▪ Each account has a maximum credit limit, a current balance, and a mailing address.
▪ The account serves one or more customers who reside at the mailing address.
▪ The institution periodically issues a statement for each account.
▪ The statement lists a payment due date, finance charge, and minimum payment. The
statement itemizes various transactions that have occurred throughout the billing interval:
cash advances, interest charges, purchases, fees, and adjustments to the account.
▪ The name of the merchant is printed for each purchase.
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Navigation of Class Models 70
Class model for managing
credit card accounts
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Traversing Class Models 71
We can pose a variety of queries against the model.
■ What transactions occurred for a credit card account within a time interval?
■ What volume of transactions were handled by an institution in the last year?
■ What customers patronized a merchant in the last year by any kind of credit card?
■ How many credit card accounts does a customer currently have?
■ What is the total maximum credit for a customer, for all accounts?
The UML incorporates a language that can express these kinds of questions—the
Object Constraint Language (OCL)
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Practical Tips 72
Tips for Constructing Class Models
• Scope ▪ Bags and sequences
• Simplicity ▪ Attributes of associations
• Diagram layout ▪ Qualified associations
• Names ▪ Generalization levels
• References ▪ Overriding features
• Multiplicity ▪ Reviews
• Association end names ▪ Documentation
Department of Computer Application 20MCA24-Software Engineering 26 August 2022
Module Important Question 99
▪ What is object orientation? ▪ Define multiplicity
▪ What are the four aspects of object oriented approach? Explain ▪ Differentiate cardinality and multiplicity
▪ Explain the terms: Identity, classification, inheritance, polymorphism ▪ Why is multiplicity significant in modeling
▪ What is object oriented development? ▪ Differentiate Bag and sequence
▪ Advantages of object oriented development ▪ Mention two situations where association end names are useful?
▪ Explain the stages of OO methodology? ▪ What is a generalization. Give examples
▪ What are the two parts of analysis model? ▪ What are qualified associations.
▪ What are the jobs of a system designer and class designer ▪ Explain how the following elements are traversed in class models
▪ What is a class diagram, state diagram, use case diagram a)attributes b)operations c)simple associations
▪ Differentiate sequence and activity diagram
▪ Explain the three system models
▪ Define abstraction and encapsulation
▪ How data and behavior can be combined in OO approach
▪ Mention the advantages of sharing code in OO approach
▪ What does OO approach emphasis on?
▪ What are the applications of OO development?
▪ Briefly discuss the history of OO modeling
▪ Differentiate internal identifiers from real world attributes
▪ What is meant by a)method b)operation
▪ Write the modeling notation for classes
▪ Differentiate links and associations
▪ How do you implement links in OO languages
Department of Computer Application 20MCA24-Software Engineering 26 August 2022