Object Modeling

You might also like

Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 40

Chapter 4

Object Modeling
Introduction to Object Modeling
Object-oriented analysis (OOA)
an approach used to
1. study existing objects to see if they can be
reused or adapted for new uses
2. define new or modified objects that will be
combined with existing objects into a useful
business computing application
Object modeling – a technique for identifying
objects within the systems environment and the
relationships between those objects.
Overview of Object-Oriented Analysis
• Object-oriented analysis is a popular approach
• sees a system from the viewpoint of the
objects themselves as they function and
interact

3
Overview of Object-Oriented Analysis
• Object-Oriented Terms
and Concepts
– Unified Modeling
Language (UML)
– Attributes
– Methods
– Message
– Class
– Instance

4
Objects, Attributes, & Instances
Object – something that is or is capable of being seen,
touched, or otherwise sensed, and about which users
store data and associate behavior.
– Person, place, thing, or event
– Employee, customer, instructor, student
– Warehouse, office, building, room
– Product, vehicle, computer, videotape

Attribute – the data that represent characteristics of


interest about an object.
Object instance – each specific person, place, thing, or
event, as well as the values for the attributes of that
object.
Objects, Attributes, & Instances
(cont.)
Overview of Object-Oriented Analysis
• Objects

7
Overview of Object-Oriented Analysis
• Objects

8
Overview of Object-Oriented Analysis
• Objects

9
10
Overview of Object-Oriented Analysis
• Attributes
– If objects are similar to nouns, attributes are
similar to adjectives that describe the
characteristics of an object
– Some objects might have a few attributes; others
might have dozens
– State:
• Describes the objects current status

11
Overview of Object-Oriented Analysis
• Methods
– A method defines
specific tasks that an
object can perform
– Just as objects are
similar to nouns and
attributes are similar to
adjectives, methods
resemble verbs that
describe what and how
an object does
something

12
Overview of Object-Oriented Analysis
• Messages
– A massage is a command that tells an object to
perform a certain method.
– A major advantage of O-O designs is that systems
analysts can save time and avoid errors by using
modular objects, and programmers can translate
the designs into code, working with reusable
program modules that have been tested and
verified

13
Method (Behavior) & Encapsulation
Behavior – the set of things that the object can do
that correspond to functions that act on the object’s
data (or attributes).
– In object-oriented circles, an object’s behavior is
commonly referred to as a method, operation, or service.

– For object “order”:


• Add order
• Delete order
• Modify order
Overview of Object-Oriented Analysis
– Polymorphism:
• The same message to two different
objects can produce different results.
– Black box:
• A messages triggers changes within the
object without specifying how the
changes must be carried out.
• E.g., Gas pump
– Blac kbox is an example of
Encapsulation:
• All data and methods are self-
contained.
• The object prevents its internal code
from being altered by another object.

15
Overview of Object-Oriented Analysis
• Classes
– An object belongs to a group or category called a
class
– All objects within a class share common attributes
and methods
– Subclasses
– Superclass

16
Overview of Object-Oriented Analysis
• Classes

17
RELATIONSHIPS AMONG OBJECTS AND
CLASSES

Relationships enable objects to communicate and interact as they


perform business functions and transactions required by the system.

Relationships describe what objects need to know about each


other, how objects respond to changes in other objects, and the
effects of membership in classes, superclasses, and subclasses.

Some relationships are stronger than others (just as a relationship


between family members is stronger than one between casual
acquaintances). The strongest relationship is called inheritance.
Inheritance enables an object, called a child, to derive one or more of
its attributes from another object, called a parent.

18
Relationships Among Objects and Classes
• Inheritance:
• enables a child object to
derive attributes from a
parent object.
• Child
• Parent

19
Relationships Among Objects and Classes
• Object Relationship Diagram:
• provides an overview of the system.

20
UML
Unified Modeling Language (UML) – a set of
modeling conventions that is used to specify or
describe a software system in terms of objects.
– The UML does not prescribe a method for
developing systems—
– only a notation that is now widely accepted as a
standard for object modeling.
– DFDs model data and processes
– UML describes OO systems
Object/Class Relationships
Object/class relationship – a natural business
association that exists between one or more
objects and classes.
Aggregation
Aggregation – a relationship in which one larger “whole” class
contains one or more smaller “parts” classes. Conversely, a
smaller “part” class is part of a “whole” larger class.
Composition
Composition – an
aggregation
relationship in
which the “whole”
is responsible for
the creation and
destruction of its
“parts.” If the
“whole” were to
die, the “part”
would die with it.
Messages
Message – communication that occurs when one
object invokes another object’s method (behavior) to
request information or some action
Object Modeling with the Unified
Modeling Language
• The UML uses a set of symbols to represent
graphically the various components and
relationships within a system
• It mainly is used to support object-oriented
systems analysis and to develop object models

26
Object Modeling with the Unified
Modeling Language
• Use Case Modeling
– Actor
– Symbol for a use case is
an oval with a label that
describes the action or
event
– Use cases also can
interact with other use
cases

27
Object Modeling with the Unified
Modeling Language
• Use Case Modeling
– When the outcome of one use case is
incorporated by another use case, we say that the
second case uses the first case

28
Use case description

29
Use Case Diagrams
– A use case diagram is a visual summary of several
related use cases within a system or subsystem
– The system boundary shows what is included in the
system (inside the rectangle) and what is not
included in the system (outside the rectangle).
– After you identify the system boundary, you place
the use cases on the diagram, add the actors, and
show the relationships

30
31
Class Diagrams
– class diagram represents a detailed view of a single
use case, shows the classes that participate in the use
case, and documents the relationship among the
classes.
– Evolves into a physical model and finally becomes a
functioning information system
– Each class appears as a rectangle, with the class name
at the top, followed by the class’s attributes and
methods
– Cardinality which describes how instances of one class
relate to instances of another class

32
Object Modeling with the UML
• Class Diagrams: represents a detailed view of a
single use case
• Show classes and their relationships

33
Sequence Diagrams
• : A sequence diagram is a dynamic model of a
use case, showing the interaction among classes
during a specified time period.
• Include symbols such as:
• Classes
• Lifelines: duration of interaction
– X: end of lifeline
• Messages
• Focuses: indicate when an object sends/receives messages

34
Sequence Diagrams
CLASSES that send or receive messages are shown at the top of the sequence
diagram.

LIFELINES A lifeline is identified by a dashed line. The lifeline represents the time
during which the object above it is able to interact with the other objects in the use
case. An X marks the end of the lifeline.

MESSAGES A message is identified by a line showing direction that runs between


two objects.

FOCUSES A focus is identified by a narrow vertical shape that covers the lifeline.
The focus indicates when an object sends or receives a message.

35
Sequence Diagrams

36
State Transition Diagrams
• show how an object changes from one state
to another, depending on events that affect
the object.

All possible states must be documented in the state


transition diagram 37
State Transition Diagrams

– The small circle to the left is the initial state, or


the point where the object first interacts with the
system
– Reading from left to right, the lines show direction
and describe the action or event that causes a
transition from one state to another
– The circle at the right with a hollow border is the
final state

38
Activity Diagrams
• Activity Diagrams: resembles a horizontal
flowchart that shows the actions and events
as they occur

39
Sequence diagrams, state transition
diagrams, and activity diagrams are
dynamic modeling tools that can help a
systems analyst understand how
objects behave and interact with the
system.

40

You might also like