Unit I-Introduction of Object Oriented Modeling
Unit I-Introduction of Object Oriented Modeling
Unit I-Introduction of Object Oriented Modeling
design
1
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.
2
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.
3
What is object-oriented?
Software is organized as a collection of
discrete objects that incorporate both data
structure and behavior.
In general it includes- identity, classification,
polymorphism and inheritance.
Object Oriented Programming Language
= Object Based Programming Language(e.g.
'83 Ada and Modula-2)
+ Inheritance + Dynamic Binding
4
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.
5
Classification
6
Polymorphism
7
Inheritance
8
Object-oriented development?
The theme is the identification and
organization of application concepts rather
than final representation in a prog. 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.
9
Object-oriented methodology
Stages-
Analysis
System design
Object design
implementation
10
Analysis - 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.
11
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.
12
Object design - The designer builds a
design model based on the analysis
model but containing implementation
details. The focus of object design is the
data structures and algorithms needed to
implement each cycle.
13
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.
14
3 models
Object model
Dynamic model
Functional model
15
Object model
16
Dynamic model
17
Functional Model
18
Object-Oriented concepts
Abstraction
Encapsulation
Combining data and behavior
Sharing
Object structure, not Procedure
Structure
Synergy
19
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.
20
21
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.
22
23
Synergy
24
Advantages of OOD……………
Used in developing Compilers, Graphics, UI,
databases, Object oriented languages, CAD
systems, simulations, etc.
Used to document existing programs that are
ill-structured and difficult to understand.
Not reduces development time; it may take
more time than conventional development
because it is intended to promote future reuse
and reduce downstream errors and
maintenance.
25
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 ( object, dynamic or
functional) and a stage of development
( analysis, design or implementation)
26
Purpose –
Testing a physical entity before building
it
Communication with customers
Visualization
Reduction of complexity
27
Object Modeling
28
Objects
31
Object diagram
32
Class diagram
33
Instance diagram
34
Person (Person) (Person) (Person)
Ram Jai
Class Diagram
Instance Diagram
35
Attribute
36
Object Modeling Notations
Person (Person) (Person)
Ram Jai
name: string 24 34
age: integer
37
Operations and Methods
An operation is a function or transformation 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.
38
Person File
name name
age size
change-job print
change-add
Operations
39
Links and Association
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.
40
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.
41
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
42
Country Has-capital City
name name Class Diagram
(Line)
L1
(Point)
(Line) P1
L2 Instance Diagram
(Line)
L3 (Point)
P2
(Line)
L4
(Line)
L5
Person
(Project) (Language)
MIS .Net
(Person)
Jai
(Project) (Language)
CAD C
45
Multiplicity
46
Link attributes
47
Accessible By
File User
Access permission
Performance rating
50
Authorized on
User Workstation
Authorization
Priority
Privileges
Start session
Home directory
Directory
52
employee employer
person Works-for company
Employee Employer
Ram TCS
Mohan Wipro
53
ordering
{ordered}
window screen
Visible-on
55
Directory File name File
A qualified association
56
organization
Company office Person
officer
57
Aggregation
It is a part-of relationship
It has transitivity property i.e. A is part of
B and B is part of C then A is part of C.
It is anti symmetric i.e. if A is a part of B
then B is not a part of A.
Aggregation is a special form of
association.
58
document paragraph sentence
Aggregation
59
Aggregation
60
Aggregation vs. Association
61
A company is an aggregation of its
divisions which are in turn aggregations
of their departments; a company is
indirectly an aggregation of departments.
A company is not an aggregation of its
employees since the company and
person are independent objects of equal
structure and status.
62
company division department
Work for
person
63
Generalization
64
Figure
Color
Pos
Thickness
Move
Select
Display
rotate
0D 1D 2D
66
lamp
fluorescent incandescent
67
Aggregation can be fixed, variable or
recursive.
A fixed aggregate has a fixed structure;
the number and types of sub parts are
predefined e.g. lamp.
A variable aggregation has a finite
number of levels but number of parts
may vary e.g. company.
68
A recursive aggregation contains directly
or indirectly an instance of the same kind
of aggregate; the number of potential
levels is unlimited e.g. computer
program.
69
program
Compound Simple
statement statement
Simple Statement:
x=i;
Block(combination of more than one simple statements):
++i;
x=i;
Compound Statement(single statement combines work of multiple
statement optionally blocks):
x=++i;
70
Propagation of operations
71
A person owns multiple documents.
Each document is composed of
paragraphs that are in turn composed of
characters. The copy operation
propagates from documents to
paragraphs to characters. Copying a
paragraph copies all the characters in it.
The operation does not propagate in
reverse direction.
72
Propagation can be possible for save,
destroy, print and lock.
Propagation of operations
73
Abstract classes
An abstract class is a class that has no
direct instances but whose descendent
classes have direct instances.
A concrete class is a class that is
instantiable i.e. it can have direct
instances.
A concrete class may have abstract
subclasses but they must have concrete
descendents.
74
only concrete classes may be leaf
classes in the inheritance tree.
75
Abstract & concrete class
subclass subclass
1+ class
1+
Has subclasses
Has subclasses
76
Abstract classes organize features common to
several classes
Abstract classes are frequently used to define
methods to be inherited by subclasses.
An abstract class can define methods to be
inherited by subclasses.
An abstract operation defines the form of an
operation for which each concrete subclass
must provide its own implementation.
77
Abstract class & abstract operation
Employee
Earning
Pay {abstract}
79
Multiple inheritance
It permits to have more than one super class
and to inherit features from all parents.
A class with more than one super class is
called a join class.
A feature from the ancestor class found along
more than one path is inherited only once.
Conflicts among parallel definitions create
ambiguities that must be resolved in
implementation.
80
vehicle
81
A hollow triangle indicates disjoint
subclasses while a solid triangle
indicates overlapping subclasses.
82
Metadata
83
A class describes a set of instances of a
given form.
Instantiation relates a class to its
instances.
The dotted arrows connect the instances
to the class.
It is also useful for documenting
examples and test cases.
84
(Person)
Name=ABC
Age=40
Weight=40
Person
Name
Age
weight
(Person)
Name=XYZ
Age=29
Weight=70
85
Class descriptors
Classes are meta objects and not real world objects.
Class descriptors have features and they have their
own classes which are called meta classes.
A class attribute describes a value common to an
entire class of objects rather than data particular to
each instance.
Class attributes are useful for storing default
information for creating new objects or summary
information about instances of the class.
A class operation is an operation on the class itself.
The most common is to create new instances.
Operations on class structure are class operations.
86
Class descriptors
Window
Size:rectangle
Visibility:boolean
Default_size:rectangle
Display
New_window
Highest_priority_window
87
Candidate keys
A candidate key is a minimal set of
attributes that uniquely identifies an
object or link.
A class may have one or more candidate
keys each of which may have different
combinations and numbers of attributes.
Each candidate key constrains the
instances in a class.
Notation is {}
88
constraints
These are functional relation between
entities of an object model.
Entity includes objects, classes,
attributes, links and associations.
A constraint restricts the values that
entities can assume.
Simple constraints may be placed in
object models and complex may be in
functional model.
89
Window
boss
Employee Length
width
salary
Constraints on objects
90
General constraints
91
Derived objects, links and attributes
92