Vous êtes sur la page 1sur 35

Chapter 19

OBJECT ORIENTED
MODELING, CONCEPTS
AND PRINCIPLES

February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 1


What is OO Development ?
 “New” way of thinking about problems using
models organized around real world concepts.
 The fundamental construct is the object
• Combines both data structure and operations in a
single entity called an object.
 Leads to reuse, faster software development and
higher quality programs.
 Easier to maintain
• Structure inherently decoupled
• Fewer side-effects

February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 3


Object Oriented Concepts
 Objects and Object Model
• Object: Data and operations relevant to some
real world or significant program entity
encapsulated into a monolithic unit accessible
only through a well defined interface. For ex.
File in the file system together with operations
such as open, close, read, & write,
• Object Model: Describes the structure of the
objects in the system
– their identity, relationships to other objects,
attributes and operations.

February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 5


Object Modeling
 Classification & Classes
• A class describes a group of objects with
similar properties (attributes), common
behavior (operations), common relationships to
other objects, and common semantics.

February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 6


Object Classes
 Thus, a class is an abstraction that describes
relevant properties and hides the rest.
Represented diagrammatically as below.

Class Name
Attributes
Operations

February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 7


Object Modeling

February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 8


Object Modeling
 Attributes: An attribute is a data value held
by the objects in a class. Name, age, and
weight are attributes of Person objects.

February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 9


Object Modeling
 Operations and Methods :
• Operations : An operation is a function or
transformation that may be applied to or by
objects in a class. Each operation has a target
object as an implicit argument. The behavior of
the operation depends on the class of its target.
• Methods : A method is the implementation of an
operation for a class.
– Categories: 1) manipulate data, 2) perform
computation, and 3) monitor for occurrence of
controlling event.

February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 10


Object Modeling
 An operation may have arguments in addition to
its target object. Such arguments parameterize the
operation but do not affect the choice of method.

February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 11


February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 12
Class and Instance
Polygon Polygon
Vertices v={(0,0),(0,1),(1,0)}
Border Color BC = Red
Fill Color FC = Blue
Draw Draw
Erase Erase
Move Move

February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 13


Abstraction and Encapsulation

February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 14


Abstraction and Encapsulation
 Abstraction
• Isolate those aspects that are important and
suppress (or hide) those that are unimportant
(e.g., representations).
• Focus on what object is and does before
deciding how it should be implemented.
• Abstraction allows dealing only with
application domain concepts, not making
design and implementation decision before
problem is understood.

February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 15


Abstraction and Encapsulation
 Encapsulation (Information Hiding)
• Separates the 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.
 Combining Data and Operations:
• The OO approach combines the data structure
and operations in a single entity.

February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 16


Interfaces

<<Interface>>
Class Name

Operations
 Does not have an implementation of its own.
 Other classes provide implementations of it.
 Client classes are only interested in behavior.

February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 17


Inheritance
 Sharing of attributes and operations among
classes based on hierarchical relationship.

February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 18


February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 19
Class and Subclass
Polygon Right Triangle
Vertices
Vertices Hypotenuse length
Border Color Border Color
Fill Color Fill Color
Draw Draw
Erase Erase

Move • Move
February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 20
February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 21
February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 22
Operations
 Polymorphism
• The same “operation” may behave differently on
different classes. E.g., the move operation behaves
differently on a Window and ChessPiece.
• Operations may be overloaded when subclasses
defined.
– The compiler can distinguish based on the type of the
operands in method invocations which operation is
actually needed.

February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 23


Polymorphism
Polygon Car
Paint Paint

Triangle Square
Paint Paint

February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 24


Communication
 Message: [destination, operation, params]

February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 25


What Does OO Mean?
 Pressman (Coad & Yourdon)
• Objects (identity)
• Classification
• Inheritance
• Communication
 Rumbaugh
• Objects (identity)
• Classification
• Inheritance
• Polymorphism

February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 26


Object Modeling Technique
 Object modeling technique (OMT) extends
from analysis thru design to implementation
 Analysis model contains objects found in
the application domain, including properties
of object and their operations.
 These application domain objects form a
framework to the design model.

February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 27


Object Modeling Technique
 The same seamless notation is used from
analysis to design to implementation.
 The system is modeled using three related
but different view points.
• Object Model : Represents the static, structural,
“data” aspects of the system.
• Dynamic Model : Represents the temporal,
behavioral, “control” aspects of the system.
• Functional Model : Represents transformational,
“functional” aspects of the system.
February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 28
Object Modeling
 Links and Associations
• Link: A physical or conceptual connection between
instances. E.g., Joe Smith Works-for Simplex
company. Mathematically, a tuple, i.e., an ordered
list of object instances. A link is an instance of an
association.
• Associations : A group of links with common
structure and semantics. E.g., a person Worksfor a
company. All the links in an association connect
objects from the same classes.

February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 29


February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 30
Object Modeling
 Multiplicity:
• Specifies how many instances of one class may
relate to a single instance of an associated class
 Role Names:
• One end of an association. Binary association
has two roles.
 Link attributes
• May be defined for associations, e.g., if the
association is “uses,” the link attribute might be
one of permission.

February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 31


Binary Association & Multiplicity

February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 32


Ternary Association

February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 33


Link Associations

February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 34


Aggregation
 A “part-whole” or “a-part-of” relationship

February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 35


Object-Oriented vs Structured Approach
 Easier to maintain  Harder to maintain
 Combines data  May separate data and
structure and behavior behavior
in a single entity  Emphasizes
 Emphasizes object procedural structure
structure  Reuse limited, hence
 Reuse more readily possible delay in
accomplished software construction

February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 41


Object-Oriented vs Structured Approach
 Strong cohesion and  Harder to achieve
weak coupling weak Coupling and
 Encapsulation, strong cohesion
Inheritance and  Some languages
Polymorphism are support encapsulation
strong features of OO and polymorphism,
software development but rarely inheritance

February 14, 1999 R. A. Volz Chapter 19 -- Assistance -- Lamimi V. Kamat 42

Vous aimerez peut-être aussi