TEXT BOOKS:
•Object-Oriented Modeling and Design with UML - Michael
Blaha, James Rumbaugh , 2nd
Edition, Pearson Education, reprint
2013.
•Frank Buschmann, Regine Meunier, Hans Rohnert, Peter
Sommerlad, Michael Stal: Pattern-Oriented Software Architecture,
A System of Patterns, Volume 1, John Wiley and Sons, 2007.
•Stephan H. Kan: Metrics and Models in Software Quality
Engineering, 2nd Edition, Pearson.
INTRODUCTION, MODELING CONCEPTS,
OOPS concept
https://www.youtube.com/watch?v=xoL6WvCARJY
Introduction
It is a new way of thinking about problems using
models based on real world concepts.
The basic construct is object which combines both
data structure and behavior in a single entity.
Rambaugh presents an object oriented software
development methodology, the Object Modeling
Technique (OMT) which extends from analysis
through design to implementation.
Analysis model is built to abstract essential aspects of
application domain which contains objects found in
application, their properties and behavior.
Then design model is made to describe and optimize
the implementation.
Finally the design model is implemented in a
programming language, database or hardware.
Graphical notation is used for expressing object-
oriented models.
OBJECT ORIENTED CONCEPTS
OBJECT
 Objects are the physical and conceptual things that exist in the 
universe.
 In programming terms, an object is a self-contained component that contains
properties and methods needed to make a certain type of data useful.
 Object is an instance of a class.
CLASS
 A class is a blueprint or template or set of instructions to build a
specific type of object.
 In programming terms, a class is a way to bind, data and functions into a
single unit.
 A class is an abstraction that describes important properties of object.
CLASS
OBJECT
CLASS vs OBJECT
What is object-oriented?
Object Oriented(OO): Software is organized as a
collection of discrete objects that incorporate both
data structure and behavior.
In general it includes 4 aspects- identity,
classification, inheritance and polymorphism.
Identity
Identity means that data is organized into discrete,
distinguishable entities called objects.
Objects can be concrete or conceptual.
In real world an object simply exist but within a
programming language each object has a unique
handle by which it can be uniquely referenced.
The handle can be implemented by address, array
index or unique value of an attribute.
Classification
It means that objects with same data structure
(attribute) and behavior (operations) are grouped into
a class.
A class is an abstraction that describes important
properties and ignores the rest.
Each class describes a possibly infinite set of
individual objects.
Object is an instance of its class.
An object has its own value for each attributes but
shares the attribute name and operations with other
instances of the classes.
Objects and classes
Polygon objects Polygon Classes                        
  
Attributes
vertices
boarder
color
Operations
Draw
Erase
Move
rectangle
parallelogram
trapezoid
Polymorphism
It means that the same operation (i.e. action or
transformation that the object performs) may behave
differently on different classes.
An operation is a procedure or transformation that
the object performs.
Specific implementation of an operation by a certain
class is called a method.
Inheritance
Inheritance
It is the sharing of attributes and operations among
classes based on a hierarchical relationship.
Super class has general information.
Subclasses can be formed from broadly defined
class[Super class].
Each subclass incorporates or inherits all the
properties of its super class and adds its own unique
properties.
Object-oriented development?
The theme is the identification and organization of
application concepts rather than final representation
in a programming Language.
OOD approach encourages software developers to
work and think in terms of the application domain
through most of the software engineering life cycle.
It is a conceptual process independent of a
programming language until the final stage.
Object-oriented methodology
Object Oriented Methodology is a methodology for
object oriented development and a graphical notation
for representing objects oriented concepts.
We can call this methodology as OMT. The
methodology has the following stages:
System Conception
Analysis
System design
Class design
Implementation
System conception
Software development begins with business analysts or user
conceiving an application and formulating tentative
requirements.
Analysis –
The analyst scrutinizes and restate the requirements from
conception by constructing model.
An analysis model is a concise, precise abstraction of what
the desired system must do, not how it will be done.
It should not contain any implementation details.
The objects in the model should be application domain
concepts and not the computer implementation concepts.
Analysis model has two parts:
Domain model: a description of the real world objects
reflected with in the system.
Application model: a description of the parts of the
application system itself that are visible to the user.
System design –
The designer makes high level decisions about the
overall architecture.
 In system design, the target system is organized as
various subsystems based on both the analysis
structure and the proposed architecture.
System designer must decide what performance
characteristics to optimize, choose strategy of
attacking the problem, and make the resource
allocations.
Class design –
Designer adds details to the analysis model in
accordance with the system design strategy.
Elaborate both domain and application objects.
Focus is on data structures and algorithms needed to
implement each class.
Implementation –
The object classes and relationships developed during
object design are finally translated into a particular
programming language, database, or hardware
implementation.
 During implementation, it is important to follow
good software engineering practice so that the system
can remain the traceability, flexibility and
extensibility.
3 models
Three kinds of models to describe a system from
different viewpoints
Class model
State model
Interaction model
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.
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.
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.
OO themes
Abstraction
Encapsulation
Combining data and behavior
Sharing
Emphasis on the Essence of an object
Synergy
Abstraction
It consists of focusing on essential aspects of an entity
and ignoring accidental properties.
The goal is to isolate those aspects that are important for
some purpose and suppress those aspects that are
unimportant.
Abstraction must always for some purpose because the
purpose determines what is and what is not important.
Many different abstractions of same thing are possible,
depending on the purpose for which they are made.
In building models, one must not search for absolute
truth but for adequacy for some purpose.
A good model captures the crucial aspects of a problem
and omits the others.
Focus on what an object is and does, not how to
implement.
Encapsulation
Information hiding
Separating external aspects of an object which are
accessible to other objects, from the internal
implementation details of the object, which are
hidden from other objects.
The implementation of an object can be changed
without affecting the applications that use it.
Encapsulation- combine data structures and behavior
in a single entity.
Combining Data and Behavior
• Caller of an operation need not consider how many
implementations of a given operation exist.
• Operator polymorphism shifts the burden of deciding what
implementation to use from the calling code to the class
hierarchy.
• As an example, let us talk about an object oriented
program calling a draw procedure for drawing different
figures say a polygon, circle, or text.
• The decision of which procedure to use is made by each
object, based on its class.
• Maintenance is easier.
Sharing
• Inheritance of both data structure and behavior lets
subclasses share common code
• The sharing of code using inheritance is one of the main
advantages of object oriented languages.
• OO development also offers the prospect of reusing
designs and code on future projects.
Synergy
Identity, Classification, polymorphism and
inheritance can be used in isolation but together they
complement each other synergistically.
Modeling
A model is an abstraction of something for the
purpose of understanding it before building it.
The word model has 2 dimensions- a view of a system
( Class, state or interaction model) and a stage of
development ( analysis, design or implementation)
Model serves several Purpose –
Testing a physical entity before building it :
 Recent advances in computation permit the simulation of many
physical structures without the need to build physical models.
Simulation is cheaper.
 Both physical model and computer model are cheaper than building
a complete system and enable early correction of flaws.
Communication with customers
 Architects and product designers build models to show their
customers. Mock-ups are demonstration product that imitate some
or all of the external behavior of a system.
Visualization
 Storyboards of movies, television shows and advertisements let writer
see how their ideas flow.
 They can modify awkward transitions, dangling ends, and
unnecessary segments before detail writing begins.
Reduction of complexity
Modeling deal with systems that are too complex to understand
directly.
Three ModelsClass Model
It represents the static, structural ,”data” aspects of a
system.
It describes the static structure of objects in a system-
their identity, relationship to other object, attribute
and operations.
It provides context for state and interaction model.
 our goal is to capture those concepts from real world
that are important to an application.
Class diagram express the class model.
The important concepts in class model are classes,
association and generalizations.
State model
It represents the temporal, behavioral, ”control”
aspects of a system.
Describes the aspects of objects concerned with time
and the sequencing of operation-events that mark
changes, states that define the context for event and
organization of state and event.
Control aspects of a system describe the sequence of
operations that occur.
State diagram express the state model.
Interaction Model
Describes the interaction between objects.
How the objects in a system cooperate to achieve
border result.
It represents the collaboration of individual objects,
the ”interaction” aspects of a system.
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.
Relationship among the Models
Each describe one aspect of the system but contains
references to the other model.
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.
Class Modeling
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.
There are two kinds of models of structure
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.
Class diagrams are useful both for abstract
modeling and designing actual program.
Person Company
Object diagram
It shows individual objects and their relationship.
A class diagram can have infinite set of object
diagram.
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.
JoeSmith: Person Adam: Person :Person
TCS: Company IBM: Company
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
name: string
age: integer
birthdate: date
JoeSmith:Person
name: “JoeSmith”
age: 20
birthdate: 1 Jan 1993
Adam:Person
name: “Adam”
age: 21
birthdate: 1 Jan 1992
Class with
Attributes
Objects with
Attributes
Class with Attributes
UML notation lists attributes in the second
compartment of the class box.
Optional details, such as type and default value,
may follow each attribute in class box.
A colon precedes the type and equal sign
precedes the default value.
List attribute name in regular face, left aligned
and use a lowercase letter for the first letter.
Object with values
UML notation includes attributes values in the
second compartment of the object box.
list each attribute name followed by an equal sign
and the value. And left align attributes values and
use regular type face.
In class model, object identifiers are implicit in
model-need not and should not list them explicitly.
Person
personID:ID
name: string
age: integer
birthdate: date
Person
name: string
age: integer
birthdate: date
Wrong
Correct
Operations and Methods
An operation is a function or procedure that may be
applied to or by objects in a class.
All objects in a class share the same operations.
The same operation may apply to many different
classes. Such an operation is polymorphic i.e. the
same operation takes on different forms in different
classes.
A method is the implementation of an operation for
a class.
When an operation has methods on several classes,
all methods must have same signature.
UML notation lists operations in the third compartment
of the class box.
List operation name in regular face, left aligned and use
a lowercase letter for the first letter.
Optional details, operation name followed by argument
list enclosed in parenthesis, commas separates the
argument and a colon precedes the result type.
Return type of operation is also optional may follow each
argument list.
Person
name
age
birthdate
netSalary
File
fileName
sizeInBytes
lastUpdate
print
GeometricObject
color
Position
move(delta: Vector)
select(p: Point): Boolean
rotate(in angle: float=0.0)
Links and Association Concepts
Links and associations are the means for establishing
relationships among objects and classes.
A link is a physical or conceptual connection between
objects.
A link is an instance of an association.
An association describes a group of links with common
structure and semantics.
All the links in an association connect objects from the
same classes.
Association and links often appear as verbs in a problem
statement.
An association describes a set of potential links in the
same way that a class describes a set of potential objects.
Associations are bidirectional.
In real, both directions of traversal are equally meaningful
and refer to same association.
Associations are often implemented in programming
languages as pointers from one object to another.
A pointer is an attribute in one object that contains an
explicit reference to another object.
A link shows a relationship between two or more objects.
All connections among classes should be modeled as
association.
One-to-one association
Many-to-many association
Ternary association
Person
name
Company
name
OwnsStock
John:Person
name=“john”
GE:Company
name=“GE”
Mary:Person
name=“mary”
Adam:Person
name=“adam”
Jeff:Person
name=“jeff”
Rena:Person
name=“rena
”
IBM:Company
name=“IBM”
Class
diagram
Object
diagram
OwnsStock
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.
Multiplicity
Multiplicity specifies how many instances of one class may
relate to each instance of another class.
Fig one-to-one association
UML list multiplicity at the end of association lines.
UML specifies multiplicity with an interval, such as ‘1’,’1….*’,or
‘3…5’.
Multiplicity is a constraint on the size of a collection;
Cardinality is the count of elements that are actually in a
collection. Therefore, multiplicity is a constraint on Cardinality
Country
name
CapitalCity
name
HasCapital
1 1
Workstation Window
console
1 0..1
Fig Zero-or-one multiplicity
Association End Names
It is the name given to end of association.
UML specifies association end name next to association end.
Use of end names is optional.
Association end name appear as noun in problem description.
It provides a means of traversing an association.
Association end name are necessary for associations between
two objects of the same class.
It also distinguish multiple associations between a pair of
classes.
It let you unify multiple references to same class.
All the names must be unique because it distinguish objects.
Person Company
WorksFor
employee employer
* 0…1
User Dictionary
owner
contents
container
authorized user
1 0..1
*
*
* *
•In Figure, container and contents distuinguish the two usages of
directory in the self –association.
•A dictionary may contain many lesser directories and may optionally
may contained itself.
•Association end name can also distuinguish multiple association
between the same pair of classes.
• In Figure each directory has exactly one user who is an owner and
many users who are authorized to use the directory.
Association end name let you unify multiple references to same
class.
When constructing class diagram, should properly use
Association end names and to introduce separate class for each
reference.
Parent Child
2
*
Person
child *
Parent
0…2
Wrong Model Correct Model
Ordering
Sometimes, the objects are explicitly ordered.
For example, the figure below shows a workstation screen
containing a number of overlapping windows. The
windows are explicitly ordered, so only the topmost
window is visible at any point on the screen.
Screen Window
*1
{ordered}
Fig .Ordering the objects for an association end
visibleOn
Bags and Sequences
Multiple links for a pair of objects are permitted by
annotating an association end with {bag} or {sequence}.
A bag is a collection of elements with duplicates allowed.
A sequence is an ordered collection of elements with
duplicates allowed.
Itinerary Airport
**
{Sequence}
Fig .An example of a sequence
Association Classes
An association Class is an association that is also a class
UML notation for an association Class is a box attached to
the association by a dashed line.
File User
**
Fig .An example of a sequence
AccessibilityBy
accessPermissio
n
User Workstatio
n**
Authorization
priority
privilege
startSession
Directory
* 1
homedirector
y
Person
name
Purchase
quatity
date
cost
Company
name* 1stock
*
1
**
OwnsStock
quantity
Person
name
Company
name
Association
Class
ordinary
Class
Qualified Associations
Qualified association is an association in which an attributes called the
qualifier disambiguates the object for a “many” association end.
A qualifier selects among the target objects, reducing the effective multiplicity,
from “many” to “one”.
UML notation for a qualifier is a small box on the end of an association line
near the source class. Qualifier box may grow out of any side.
Bank
Account
accnum
1 *
Fig . Not qualified
Bank
Accountaccnum
Fig . Qualified
1 0..1
StockExchange
tickerSymbo
l
StockExchange
*
0..1
lists
StockExchange
StockExchange
*
lists
*
tickerSymbo
l
Qualified Not qualified
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.
It is “is-a” relationship because each instance of a sub class is
an instance of super class as well.
UML notation for a generalization is a large hollow
arrowhead. The arrowhead points to the super class.
Super class may directly connect to each subclass, but
normally prefer to group subclass as a tree.
A generalization set name is an enumerated attribute that
indicates which aspect of an object is being abstracted by a
particular generalization.
Fig. Inheritance for graphic figure
Figure
color
centerPosition
penThickness
penType
move
select
rotate
display
ZeroDimensional OneDimensional
orientation
scale
TwoDimensional
Orientation
fillType
scale
fill
Line
endPoint
display
Point
display
Arc
radius
startAngl
e
arcAngle
display
Spline
controlPt
s
display
Polygon
numOfSide
s
vertices
display
Circle
diameter
display
rotate
dimentionality
Use of generalization
Generalization has three purpose.
1. It support for polymorphism.
2. It structure the description of objects.
3. It enable reuse of code.
The word generalization derives from the fact that the
superclass generalizes the subclass.
The word specialization refers to the fact that the subclass
refine or specialize the superclass.
Inheritance is the mechanism for sharing attributes,
operations and association via the generalization/
specialization relationship.
Overriding features
A subclass may override a superclass feature by defining a
feature with the same name.
The overriding features(the subclass feature) refines and
replaces the overridden feature(the superclass feature) .
Method and default values of attribute can be override,
but never override the signature of a feature.
An overriding should preserve attribute types, number
and type of arguments to an operation, and operation
return type.
Navigation of class models
Navigation is important because it lets you exercise a
model and uncover hidden flaws and omissions so
that you can repair them.
It is possible to perform navigation manually or write
navigation expressions.
UML incorporates a language that express several
kinds of question asked on model—object constraint
language(OCL)
OCL constructs for traversing class model
Attributes
Operations
Simple Association
Qualified Association
Generalization
Filters
Refer TB for credit card related class diagram. OCL
queries in next few slides are written for that diagram.
Use OCL to answer credit card Questions.
What transaction occurred for a credit card account
within a time interval.
aCreditCardAccount.Statement.Transaction ->select
(aStartDate <= transactionDate and transactionDate <=
anEndDate )
What volume of transanctions held by an
institution in the last year?
anInstitution.CreditCardAccount.Statement.Transaction ->
select(aStartDate <= transactionDate and transactionDate
<= anEndDate ).amount -> sum()
How many credit card account does a customer
currently have?
aCustomer.MailingAddress.CreditCardAccount -> size()
What is the total maximum credit for a customer, for all
accounts?
aCustomer.MailingAddress.CreditCardAccount
.maxmumCredit-> sum()

Oomd unit1

  • 1.
     TEXT BOOKS: •Object-Oriented Modeling and Design with UML - Michael Blaha, JamesRumbaugh , 2nd Edition, Pearson Education, reprint 2013. •Frank Buschmann, Regine Meunier, Hans Rohnert, Peter Sommerlad, Michael Stal: Pattern-Oriented Software Architecture, A System of Patterns, Volume 1, John Wiley and Sons, 2007. •Stephan H. Kan: Metrics and Models in Software Quality Engineering, 2nd Edition, Pearson.
  • 2.
  • 3.
  • 4.
    Introduction It is anew way of thinking about problems using models based on real world concepts. The basic construct is object which combines both data structure and behavior in a single entity. Rambaugh presents an object oriented software development methodology, the Object Modeling Technique (OMT) which extends from analysis through design to implementation.
  • 5.
    Analysis model isbuilt to abstract essential aspects of application domain which contains objects found in application, their properties and behavior. Then design model is made to describe and optimize the implementation. Finally the design model is implemented in a programming language, database or hardware. Graphical notation is used for expressing object- oriented models.
  • 6.
    OBJECT ORIENTED CONCEPTS OBJECT Objects are the physical and conceptual things that exist in the  universe.  In programming terms, an object is a self-contained component that contains properties and methods needed to make a certain type of data useful.  Object is an instance of a class. CLASS  A class is a blueprint or template or set of instructions to build a specific type of object.  In programming terms, a class is a way to bind, data and functions into a single unit.  A class is an abstraction that describes important properties of object.
  • 7.
  • 8.
  • 9.
  • 10.
    What is object-oriented? Object Oriented(OO): Softwareis organized as a collection of discrete objects that incorporate both data structure and behavior. In general it includes 4 aspects- identity, classification, inheritance and polymorphism.
  • 11.
    Identity Identity means thatdata is organized into discrete, distinguishable entities called objects. Objects can be concrete or conceptual. In real world an object simply exist but within a programming language each object has a unique handle by which it can be uniquely referenced. The handle can be implemented by address, array index or unique value of an attribute.
  • 12.
    Classification It means thatobjects with same data structure (attribute) and behavior (operations) are grouped into a class. A class is an abstraction that describes important properties and ignores the rest. Each class describes a possibly infinite set of individual objects. Object is an instance of its class. An object has its own value for each attributes but shares the attribute name and operations with other instances of the classes.
  • 13.
    Objects and classes Polygonobjects Polygon Classes                            Attributes vertices boarder color Operations Draw Erase Move rectangle parallelogram trapezoid
  • 15.
    Polymorphism It means thatthe same operation (i.e. action or transformation that the object performs) may behave differently on different classes. An operation is a procedure or transformation that the object performs. Specific implementation of an operation by a certain class is called a method.
  • 16.
  • 17.
    Inheritance It is thesharing of attributes and operations among classes based on a hierarchical relationship. Super class has general information. Subclasses can be formed from broadly defined class[Super class]. Each subclass incorporates or inherits all the properties of its super class and adds its own unique properties.
  • 18.
    Object-oriented development? The themeis the identification and organization of application concepts rather than final representation in a programming Language. OOD approach encourages software developers to work and think in terms of the application domain through most of the software engineering life cycle. It is a conceptual process independent of a programming language until the final stage.
  • 19.
    Object-oriented methodology Object OrientedMethodology is a methodology for object oriented development and a graphical notation for representing objects oriented concepts. We can call this methodology as OMT. The methodology has the following stages: System Conception Analysis System design Class design Implementation
  • 20.
    System conception Software developmentbegins with business analysts or user conceiving an application and formulating tentative requirements. Analysis – The analyst scrutinizes and restate the requirements from conception by constructing model. An analysis model is a concise, precise abstraction of what the desired system must do, not how it will be done. It should not contain any implementation details. The objects in the model should be application domain concepts and not the computer implementation concepts. Analysis model has two parts: Domain model: a description of the real world objects reflected with in the system. Application model: a description of the parts of the application system itself that are visible to the user.
  • 21.
    System design – Thedesigner makes high level decisions about the overall architecture.  In system design, the target system is organized as various subsystems based on both the analysis structure and the proposed architecture. System designer must decide what performance characteristics to optimize, choose strategy of attacking the problem, and make the resource allocations.
  • 22.
    Class design – Designeradds details to the analysis model in accordance with the system design strategy. Elaborate both domain and application objects. Focus is on data structures and algorithms needed to implement each class.
  • 23.
    Implementation – The objectclasses and relationships developed during object design are finally translated into a particular programming language, database, or hardware implementation.  During implementation, it is important to follow good software engineering practice so that the system can remain the traceability, flexibility and extensibility.
  • 24.
    3 models Three kindsof models to describe a system from different viewpoints Class model State model Interaction model
  • 25.
    Class model Describes basicstructure 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.
  • 26.
    State model Describes theaspects 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.
  • 27.
    Interaction Model Describes howthe 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.
  • 28.
    OO themes Abstraction Encapsulation Combining dataand behavior Sharing Emphasis on the Essence of an object Synergy
  • 30.
    Abstraction It consists offocusing on essential aspects of an entity and ignoring accidental properties. The goal is to isolate those aspects that are important for some purpose and suppress those aspects that are unimportant. Abstraction must always for some purpose because the purpose determines what is and what is not important. Many different abstractions of same thing are possible, depending on the purpose for which they are made. In building models, one must not search for absolute truth but for adequacy for some purpose. A good model captures the crucial aspects of a problem and omits the others. Focus on what an object is and does, not how to implement.
  • 33.
    Encapsulation Information hiding Separating externalaspects of an object which are accessible to other objects, from the internal implementation details of the object, which are hidden from other objects. The implementation of an object can be changed without affecting the applications that use it. Encapsulation- combine data structures and behavior in a single entity.
  • 34.
    Combining Data andBehavior • Caller of an operation need not consider how many implementations of a given operation exist. • Operator polymorphism shifts the burden of deciding what implementation to use from the calling code to the class hierarchy. • As an example, let us talk about an object oriented program calling a draw procedure for drawing different figures say a polygon, circle, or text. • The decision of which procedure to use is made by each object, based on its class. • Maintenance is easier.
  • 35.
    Sharing • Inheritance ofboth data structure and behavior lets subclasses share common code • The sharing of code using inheritance is one of the main advantages of object oriented languages. • OO development also offers the prospect of reusing designs and code on future projects.
  • 36.
    Synergy Identity, Classification, polymorphismand inheritance can be used in isolation but together they complement each other synergistically.
  • 37.
    Modeling A model isan abstraction of something for the purpose of understanding it before building it. The word model has 2 dimensions- a view of a system ( Class, state or interaction model) and a stage of development ( analysis, design or implementation)
  • 38.
    Model serves severalPurpose – Testing a physical entity before building it :  Recent advances in computation permit the simulation of many physical structures without the need to build physical models. Simulation is cheaper.  Both physical model and computer model are cheaper than building a complete system and enable early correction of flaws. Communication with customers  Architects and product designers build models to show their customers. Mock-ups are demonstration product that imitate some or all of the external behavior of a system. Visualization  Storyboards of movies, television shows and advertisements let writer see how their ideas flow.  They can modify awkward transitions, dangling ends, and unnecessary segments before detail writing begins. Reduction of complexity Modeling deal with systems that are too complex to understand directly.
  • 39.
    Three ModelsClass Model Itrepresents the static, structural ,”data” aspects of a system. It describes the static structure of objects in a system- their identity, relationship to other object, attribute and operations. It provides context for state and interaction model.  our goal is to capture those concepts from real world that are important to an application. Class diagram express the class model. The important concepts in class model are classes, association and generalizations.
  • 40.
    State model It representsthe temporal, behavioral, ”control” aspects of a system. Describes the aspects of objects concerned with time and the sequencing of operation-events that mark changes, states that define the context for event and organization of state and event. Control aspects of a system describe the sequence of operations that occur. State diagram express the state model.
  • 41.
    Interaction Model Describes theinteraction between objects. How the objects in a system cooperate to achieve border result. It represents the collaboration of individual objects, the ”interaction” aspects of a system. 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.
  • 42.
    Relationship among theModels Each describe one aspect of the system but contains references to the other model. 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.
  • 43.
  • 44.
    Object and Classconcepts 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.
  • 45.
    There are twokinds of models of structure 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. Class diagrams are useful both for abstract modeling and designing actual program. Person Company
  • 46.
    Object diagram It showsindividual objects and their relationship. A class diagram can have infinite set of object diagram. 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. JoeSmith: Person Adam: Person :Person TCS: Company IBM: Company
  • 47.
    Values and Attributes AValue 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 name: string age: integer birthdate: date JoeSmith:Person name: “JoeSmith” age: 20 birthdate: 1 Jan 1993 Adam:Person name: “Adam” age: 21 birthdate: 1 Jan 1992 Class with Attributes Objects with Attributes
  • 48.
    Class with Attributes UMLnotation lists attributes in the second compartment of the class box. Optional details, such as type and default value, may follow each attribute in class box. A colon precedes the type and equal sign precedes the default value. List attribute name in regular face, left aligned and use a lowercase letter for the first letter. Object with values UML notation includes attributes values in the second compartment of the object box. list each attribute name followed by an equal sign and the value. And left align attributes values and use regular type face.
  • 49.
    In class model,object identifiers are implicit in model-need not and should not list them explicitly. Person personID:ID name: string age: integer birthdate: date Person name: string age: integer birthdate: date Wrong Correct
  • 50.
    Operations and Methods Anoperation is a function or procedure that may be applied to or by objects in a class. All objects in a class share the same operations. The same operation may apply to many different classes. Such an operation is polymorphic i.e. the same operation takes on different forms in different classes. A method is the implementation of an operation for a class. When an operation has methods on several classes, all methods must have same signature.
  • 51.
    UML notation listsoperations in the third compartment of the class box. List operation name in regular face, left aligned and use a lowercase letter for the first letter. Optional details, operation name followed by argument list enclosed in parenthesis, commas separates the argument and a colon precedes the result type. Return type of operation is also optional may follow each argument list. Person name age birthdate netSalary File fileName sizeInBytes lastUpdate print GeometricObject color Position move(delta: Vector) select(p: Point): Boolean rotate(in angle: float=0.0)
  • 52.
    Links and AssociationConcepts Links and associations are the means for establishing relationships among objects and classes. A link is a physical or conceptual connection between objects. A link is an instance of an association. An association describes a group of links with common structure and semantics. All the links in an association connect objects from the same classes. Association and links often appear as verbs in a problem statement. An association describes a set of potential links in the same way that a class describes a set of potential objects.
  • 53.
    Associations are bidirectional. Inreal, both directions of traversal are equally meaningful and refer to same association. Associations are often implemented in programming languages as pointers from one object to another. A pointer is an attribute in one object that contains an explicit reference to another object. A link shows a relationship between two or more objects. All connections among classes should be modeled as association. One-to-one association Many-to-many association Ternary association
  • 54.
  • 55.
    Multiplicity It specifies howmany 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.
  • 56.
    Multiplicity Multiplicity specifies howmany instances of one class may relate to each instance of another class. Fig one-to-one association UML list multiplicity at the end of association lines. UML specifies multiplicity with an interval, such as ‘1’,’1….*’,or ‘3…5’. Multiplicity is a constraint on the size of a collection; Cardinality is the count of elements that are actually in a collection. Therefore, multiplicity is a constraint on Cardinality Country name CapitalCity name HasCapital 1 1
  • 57.
    Workstation Window console 1 0..1 FigZero-or-one multiplicity
  • 58.
    Association End Names Itis the name given to end of association. UML specifies association end name next to association end. Use of end names is optional. Association end name appear as noun in problem description. It provides a means of traversing an association. Association end name are necessary for associations between two objects of the same class. It also distinguish multiple associations between a pair of classes. It let you unify multiple references to same class. All the names must be unique because it distinguish objects. Person Company WorksFor employee employer * 0…1
  • 59.
    User Dictionary owner contents container authorized user 10..1 * * * * •In Figure, container and contents distuinguish the two usages of directory in the self –association. •A dictionary may contain many lesser directories and may optionally may contained itself. •Association end name can also distuinguish multiple association between the same pair of classes. • In Figure each directory has exactly one user who is an owner and many users who are authorized to use the directory.
  • 60.
    Association end namelet you unify multiple references to same class. When constructing class diagram, should properly use Association end names and to introduce separate class for each reference. Parent Child 2 * Person child * Parent 0…2 Wrong Model Correct Model
  • 61.
    Ordering Sometimes, the objectsare explicitly ordered. For example, the figure below shows a workstation screen containing a number of overlapping windows. The windows are explicitly ordered, so only the topmost window is visible at any point on the screen. Screen Window *1 {ordered} Fig .Ordering the objects for an association end visibleOn
  • 62.
    Bags and Sequences Multiplelinks for a pair of objects are permitted by annotating an association end with {bag} or {sequence}. A bag is a collection of elements with duplicates allowed. A sequence is an ordered collection of elements with duplicates allowed. Itinerary Airport ** {Sequence} Fig .An example of a sequence
  • 63.
    Association Classes An associationClass is an association that is also a class UML notation for an association Class is a box attached to the association by a dashed line. File User ** Fig .An example of a sequence AccessibilityBy accessPermissio n
  • 64.
  • 65.
    Qualified Associations Qualified associationis an association in which an attributes called the qualifier disambiguates the object for a “many” association end. A qualifier selects among the target objects, reducing the effective multiplicity, from “many” to “one”. UML notation for a qualifier is a small box on the end of an association line near the source class. Qualifier box may grow out of any side. Bank Account accnum 1 * Fig . Not qualified Bank Accountaccnum Fig . Qualified 1 0..1
  • 66.
  • 67.
    Generalization and Inheritance Generalizationis a relationship between a super class and subclass. Each subclass is said to be inherit the features of its super class. It is “is-a” relationship because each instance of a sub class is an instance of super class as well. UML notation for a generalization is a large hollow arrowhead. The arrowhead points to the super class. Super class may directly connect to each subclass, but normally prefer to group subclass as a tree. A generalization set name is an enumerated attribute that indicates which aspect of an object is being abstracted by a particular generalization.
  • 68.
    Fig. Inheritance forgraphic figure Figure color centerPosition penThickness penType move select rotate display ZeroDimensional OneDimensional orientation scale TwoDimensional Orientation fillType scale fill Line endPoint display Point display Arc radius startAngl e arcAngle display Spline controlPt s display Polygon numOfSide s vertices display Circle diameter display rotate dimentionality
  • 69.
    Use of generalization Generalizationhas three purpose. 1. It support for polymorphism. 2. It structure the description of objects. 3. It enable reuse of code. The word generalization derives from the fact that the superclass generalizes the subclass. The word specialization refers to the fact that the subclass refine or specialize the superclass. Inheritance is the mechanism for sharing attributes, operations and association via the generalization/ specialization relationship.
  • 70.
    Overriding features A subclassmay override a superclass feature by defining a feature with the same name. The overriding features(the subclass feature) refines and replaces the overridden feature(the superclass feature) . Method and default values of attribute can be override, but never override the signature of a feature. An overriding should preserve attribute types, number and type of arguments to an operation, and operation return type.
  • 71.
    Navigation of classmodels Navigation is important because it lets you exercise a model and uncover hidden flaws and omissions so that you can repair them. It is possible to perform navigation manually or write navigation expressions. UML incorporates a language that express several kinds of question asked on model—object constraint language(OCL)
  • 72.
    OCL constructs fortraversing class model Attributes Operations Simple Association Qualified Association Generalization Filters Refer TB for credit card related class diagram. OCL queries in next few slides are written for that diagram.
  • 73.
    Use OCL toanswer credit card Questions. What transaction occurred for a credit card account within a time interval. aCreditCardAccount.Statement.Transaction ->select (aStartDate <= transactionDate and transactionDate <= anEndDate )
  • 74.
    What volume oftransanctions held by an institution in the last year? anInstitution.CreditCardAccount.Statement.Transaction -> select(aStartDate <= transactionDate and transactionDate <= anEndDate ).amount -> sum() How many credit card account does a customer currently have? aCustomer.MailingAddress.CreditCardAccount -> size() What is the total maximum credit for a customer, for all accounts? aCustomer.MailingAddress.CreditCardAccount .maxmumCredit-> sum()