Introduction To Object Modeling (1) - 065316
Introduction To Object Modeling (1) - 065316
TO OBJECT
MODELING stide
facilitator: Engr sunjo Ari
.com
Email: aris.sunjo@gmail
COURSE OUTLINE
1. Basic techniques of modeling computer system
2. Overview of prominent object-oriented Methodologies
3. Introduction to UML (Unified Modeling Language)
4. Overview of the development process
5. Study of the various UML diagrams (structural and behavioral diagrams)
6. Class diagram (attributes, association, aggregation, composition, generalization, parameterized classes)
7. Use Case diagram
8. Interaction diagram (sequence diagram, collaboration diagram)
9. State diagram and activity diagram
10. Introduction to Object-oriented design (inheritance, encapsulation, polymorphism, abstract interfaces,
parameterized types)
11. Design patterns in OOD modeling of the source code modeling executable versions
12. Workshop on object oriented software engineering.
BASIC TECHNIQUES OF
MODELING COMPUTER
SYSTEM
WHAT IS A MODEL?
A model is a mathematical representation of a
physical, biological or information system. Models allow us
to reason about a system and make predictions about how a
system will behave. In this text, we will mainly be
interested in models describing the input/output behavior of
systems and often in so-called “state space” form.
WHY DO WE NEED
TO MODEL IN IT?
WHY MODEL?
We need to model complex systems in the real world in order to understand them. For
example: we create computerized models of the real world to manipulate large amounts of data
and hence derive information which can assist in decision making.
An analysts will create diagrammatic models of a target or proposed system in order to:
• understand the system, and
• communicate:
• to demonstrate, or clarify, understanding of the existing system and/or to obtain feedback from
users/clients;
• to describe unambiguously the proposed computer system to users/clients and to the programming team.
Modeling techniques are extremely useful in tackling the complexity which is found when
attempting to analyze and understand a system. Models are also extremely useful
communication tools; ie: complex ideas and concepts can be captured on paper and can be
shown to users and clients for clarification and feedback; or for distribution to other
professionals, team members, contractors etc. In this respect, the final models created in the
Design and Development phases of a system are essentially paper based prototypes.
MODELING TECHNIQUES
The three most important modeling techniques
used in analyzing and building information
systems are:
• Data Flow Diagramming (DFDs)
• Logical Data Structure modelling (LDSs) and
• Entity Life Histories (ELHs)
DATA FLOW DIAGRAMS (DFDS)
Data Flow
Diagrams (DFDs) model events and processes (i
.e. activities which transform data) within a
system. DFDs examine how data flows into, out
of, and within the system. (Note: 'data' can be
understood as any 'thing' (e.g.: raw materials,
filed information, ideas, etc.) which is processed
within the system.
LOGICAL DATA
STRUCTURES (LDSS)
Logical Data
Structures (LDSs) represent a
system's information and data in
another way. LDSs map the
underlying data structures as entity
types, entity attributes, and the
relationships between the entities.
ENTITY LIFE HISTORIES (ELHS)
Entity Life
Histories (ELHs) describe the
changes which happen to 'things'
(entities) within the system.
DFD PRINCIPLES
• The general principle in Data Flow Diagramming is that a system can be decomposed
into subsystems, and subsystems can be decomposed into lower level subsystems, and
so on.
• Each subsystem represents a process or activity in which data is processed. At the
lowest level, processes can no longer be decomposed.
• Each 'process' (and from now on, by 'process' we mean subsystem and activity) in a
DFD has the characteristics of a system.
• Just as a system must have input and output (if it is not dead), so a process must have
input and output.
• Data enters the system from the environment; data flows between processes within the
system; and data is produced as output from the system
BASIC DFD NOTATIONS
In a DFD,
a process may be shown as a circle, an oval, or
(typically) a rectangular box; and
data are shown as arrows coming to, or going from
the edge of the process box.
In SSADM (Structured Systems Analysis and
Design Methodology)
SSADM USES 4 DIAGRAMMING
NOTATIONS IN DFDS
• Processes transform or manipulate data. Each box has a unique
number as identifier (top left) and a unique name (an imperative -
eg: 'do this' - statement in the main box area) The top line is used
for the location of, or the people responsible for, the process.
• Data Flows depict data/information flowing to or from a process.
The arrows used to represent the flows must either start and/or
end at a process box.
• Data Stores are some location where data is held temporarily or
permanently.
• External Entities , also known as 'External source/recipients, are
things (eg: people, machines, organizations etc.) which contribute
data or information to the system or which receive
data/information from it.
DFD LEVELS
For ease of reference, part of the contents are extracted from the full manual and summarized in the
3. OOM Overview
Object Oriented Methodology (OOM) is a system development approach
encouraging and facilitating re-use of software components. With this
methodology, a computer system can be developed on a component basis which
enables the effective re-use of existing components and facilitates the sharing
of its components by other systems. Through the adoption of OOM, higher
productivity, lower maintenance cost and better quality can be achieved.
UML is made up of −
• Diagrams − It is a pictorial representations of process, system, or
some part of it.
• Notations − It consists of elements that work together in a
diagram such as connectors, symbols, notes, etc.
EXAMPLE OF UML NOTATION FOR CLASS
INSTANCE DIAGRAM-UML NOTATION
OPERATIONS PERFORMED ON OBJECTS
Following is a sample use case diagram representing the order management system. Hence, if
we look into the diagram then we will find three use cases (Order, SpecialOrder, and
NormalOrder) and one actor which is the customer.
The SpecialOrder and NormalOrder use cases are extended from Order use case. Hence, they
have extended relationship. Another important point is to identify the system boundary, which
is shown in the picture. The actor Customer lies outside the system as it is an external user of
the system.
WHERE TO USE A USE CASE DIAGRAM?
As we have already discussed there are five diagrams in UML to model the dynamic view of
a system. Now each and every model has some specific purpose to use. Actually these
specific purposes are different angles of a running system.
To understand the dynamics of a system, we need to use different types of diagrams. Use
case diagram is one of them and its specific purpose is to gather system requirements and
actors.
Use case diagrams specify the events of a system and their flows. But use case diagram
never describes how they are implemented. Use case diagram can be imagined as a black
box where only the input, output, and the function of the black box is known.
These diagrams are used at a very high level of design. This high level design is refined
again and again to get a complete and practical picture of the system. A well-structured use
case also describes the pre-condition, post condition, and exceptions. These extra elements
are used to make test cases when performing the testing.
Although use case is not a good candidate for forward and reverse engineering, still
they are used in a slightly different way to make forward and reverse engineering.
The same is true for reverse engineering. Use case diagram is used differently to
make it suitable for reverse engineering.
In forward engineering, use case diagrams are used to make test cases and in reverse
engineering use cases are used to prepare the requirement details from the existing
application.
Use case diagrams can be used for −
Requirement analysis and high level design.
Model the context of a system.
Reverse engineering.
Forward engineering.
INTERACTION
DIAGRAM
DEFINITION
From the term Interaction, it is clear that the diagram is used to describe some type
of interactions among the different elements in the model. This interaction is a part
of dynamic behavior of the system.
This interactive behavior is represented in UML by two diagrams known as
Sequence diagram and Collaboration diagram. The basic purpose of both the
diagrams are similar.
Sequence diagram emphasizes on time sequence of messages and collaboration
diagram emphasizes on the structural organization of the objects that send and
receive messages.
PURPOSE OF INTERACTION DIAGRAMS
The purpose of interaction diagrams is to visualize the interactive behavior of the system.
Visualizing the interaction is a difficult task. Hence, the solution is to use different types of
models to capture the different aspects of the interaction.
Sequence and collaboration diagrams are used to capture the dynamic nature but from a
different angle.
The purpose of interaction diagram is −
To capture the dynamic behavior of a system.
To describe the message flow in the system.
To describe the structural organization of the objects.
To describe the interaction among objects.
HOW TO DRAW AN INTERACTION
DIAGRAM?
As we have already discussed, the purpose of interaction diagrams is to capture the dynamic aspect of a system.
So to capture the dynamic aspect, we need to understand what a dynamic aspect is and how it is visualized.
Dynamic aspect can be defined as the snapshot of the running system at a particular moment
We have two types of interaction diagrams in UML. One is the sequence diagram and the other is the
collaboration diagram. The sequence diagram captures the time sequence of the message flow from one object
to another and the collaboration diagram describes the organization of objects in a system taking part in the
message flow.
Following things are to be identified clearly before drawing the interaction diagram
Objects taking part in the interaction.
Message flows among the objects.
The sequence in which the messages are flowing.
Object organization.
Following are two interaction diagrams modeling the order management system. The first diagram is a
sequence diagram and the second is a collaboration diagram
THE SEQUENCE DIAGRAM
The sequence diagram has four objects (Customer, Order, SpecialOrder and
NormalOrder).
The following diagram shows the message sequence for SpecialOrder object and
the same can be used in case of NormalOrder object. It is important to understand
the time sequence of message flows. The message flow is nothing but a method
call of an object.
The first call is sendOrder () which is a method of Order object. The next call is
confirm () which is a method of SpecialOrder object and the last call is Dispatch ()
which is a method of SpecialOrder object. The following diagram mainly
describes the method calls from one object to another, and this is also the actual
scenario when the system is running.
THE COLLABORATION
DIAGRAM
The second interaction diagram is the collaboration diagram. It shows the object
organization as seen in the following diagram. In the collaboration diagram, the method call
sequence is indicated by some numbering technique. The number indicates how the
methods are called one after another. We have taken the same order management system to
describe the collaboration diagram.
Method calls are similar to that of a sequence diagram. However, difference being the
sequence diagram does not describe the object organization, whereas the collaboration
diagram shows the object organization.
To choose between these two diagrams, emphasis is placed on the type of requirement. If
the time sequence is important, then the sequence diagram is used. If organization is
required, then collaboration diagram is used.
WHERE TO USE INTERACTION
DIAGRAMS?
We have already discussed that interaction diagrams are used to describe the dynamic nature
of a system. Now, we will look into the practical scenarios where these diagrams are used. To
understand the practical application, we need to understand the basic nature of sequence and
collaboration diagram.
The main purpose of both the diagrams are similar as they are used to capture the dynamic
behavior of a system. However, the specific purpose is more important to clarify and
understand.
Sequence diagrams are used to capture the order of messages flowing from one object to
another. Collaboration diagrams are used to describe the structural organization of the objects
taking part in the interaction. A single diagram is not sufficient to describe the dynamic aspect
of an entire system, so a set of diagrams are used to capture it as a whole.
Interaction diagrams are used when we want to understand the message
flow and the structural organization. Message flow means the sequence
of control flow from one object to another. Structural organization
means the visual organization of the elements in a system.
Interaction diagrams can be used −
To model the flow of control by time sequence.
To model the flow of control by structural organizations.
For forward engineering.
For reverse engineering.
STATECHART
DIAGRAMS
DEFINITION
The name of the diagram itself clarifies the purpose of the diagram and other
details. It describes different states of a component in a system. The states are
specific to a component/object of a system.
A Statechart diagram describes a state machine. State machine can be defined
as a machine which defines different states of an object and these states are
controlled by external or internal events.
Activity diagram explained in the next chapter, is a special kind of a Statechart
diagram. As Statechart diagram defines the states, it is used to model the
lifetime of an object.
PURPOSE OF STATECHART DIAGRAMS
Statechart diagram is one of the five UML diagrams used to model the dynamic nature of a
system. They define different states of an object during its lifetime and these states are
changed by events. Statechart diagrams are useful to model the reactive systems. Reactive
systems can be defined as a system that responds to external or internal events.
Statechart diagram describes the flow of control from one state to another state. States are
defined as a condition in which an object exists and it changes when some event is triggered.
The most important purpose of Statechart diagram is to model lifetime of an object from
creation to termination.
Statechart diagrams are also used for forward and reverse engineering of a system. However,
the main purpose is to model the reactive system.
Following are the main purposes of using Statechart diagrams −
To model the dynamic aspect of a system.
To model the life time of a reactive system.
To describe different states of an object during its life time.
Define a state machine to model the states of an object.
HOW TO DRAW A STATECHART DIAGRAM?
Statechart diagram is used to describe the states of different objects in its life cycle.
Emphasis is placed on the state changes upon some internal or external events.
These states of objects are important to analyze and implement them accurately.
Statechart diagrams are very important for describing the states. States can be
identified as the condition of objects when a particular event occurs.
Before drawing a Statechart diagram we should clarify the following points −
Identify the important objects to be analyzed.
Identify the states.
Identify the events.
Following is an example of a Statechart diagram where the state of
Order object is analyzed
The first state is an idle state from where the process starts. The next
states are arrived for events like send request, confirm request, and
dispatch order. These events are responsible for the state changes of
order object.
During the life cycle of an object (here order object) it goes through the
following states and there may be some abnormal exits. This abnormal
exit may occur due to some problem in the system. When the entire life
cycle is complete, it is considered as a complete transaction as shown in
the following figure. The initial and final state of an object is also
shown in the following figure.
WHERE TO USE STATECHART DIAGRAMS?
From the above discussion, we can define the practical applications of a Statechart
diagram. Statechart diagrams are used to model the dynamic aspect of a system like other
four diagrams discussed in this tutorial. However, it has some distinguishing
characteristics for modeling the dynamic nature.
Statechart diagram defines the states of a component and these state changes are dynamic
in nature. Its specific purpose is to define the state changes triggered by events. Events are
internal or external factors influencing the system.
Statechart diagrams are used to model the states and also the events operating on the
system. When implementing a system, it is very important to clarify different states of an
object during its life time and Statechart diagrams are used for this purpose. When these
states and events are identified, they are used to model it and these models are used during
the implementation of the system.
If we look into the practical implementation of Statechart diagram, then it is
mainly used to analyze the object states influenced by events. This analysis is
helpful to understand the system behavior during its execution.
The main usage can be described as −
To model the object states of a system.
To model the reactive system. Reactive system consists of reactive objects.
To identify the events responsible for state changes.
Forward and reverse engineering.
ACTIVITY
DIAGRAMS
DEFINITION
Activity diagram is another important diagram in UML to describe the
dynamic aspects of the system.
Activity diagram is basically a flowchart to represent the flow from one
activity to another activity. The activity can be described as an operation of the
system.
The control flow is drawn from one operation to another. This flow can be
sequential, branched, or concurrent. Activity diagrams deal with all type of
flow control by using different elements such as fork, join, etc
PURPOSE OF ACTIVITY
DIAGRAMS
The basic purposes of activity diagrams is similar to other four diagrams. It captures the
dynamic behavior of the system. Other four diagrams are used to show the message flow
from one object to another but activity diagram is used to show message flow from one
activity to another.
Activity is a particular operation of the system. Activity diagrams are not only used for
visualizing the dynamic nature of a system, but they are also used to construct the
executable system by using forward and reverse engineering techniques. The only missing
thing in the activity diagram is the message part.
It does not show any message flow from one activity to another. Activity diagram is
sometimes considered as the flowchart. Although the diagrams look like a flowchart, they
are not. It shows different flows such as parallel, branched, concurrent, and single.
The purpose of an activity diagram can be described as −
Draw the activity flow of a system.
Describe the sequence from one activity to another.
Describe the parallel, branched and concurrent flow of the system.
HOW TO DRAW AN ACTIVITY DIAGRAM?
Activity diagrams are mainly used as a flowchart that consists of activities performed by the
system. Activity diagrams are not exactly flowcharts as they have some additional
capabilities. These additional capabilities include branching, parallel flow, swimlane, etc.
Before drawing an activity diagram, we must have a clear understanding about the elements
used in activity diagram. The main element of an activity diagram is the activity itself. An
activity is a function performed by the system. After identifying the activities, we need to
understand how they are associated with constraints and conditions.
Before drawing an activity diagram, we should identify the following elements −
Activities
Association
Conditions
Constraints
Once the above-mentioned parameters are identified, we need to make a mental layout of the
entire flow. This mental layout is then transformed into an activity diagram.
Following is an example of an activity diagram for order management system. In the
diagram, four activities are identified which are associated with conditions. One important
point should be clearly understood that an activity diagram cannot be exactly matched with
the code. The activity diagram is made to understand the flow of activities and is mainly
used by the business users
Following diagram is drawn with the four main activities −
Send order by the customer
Receipt of the order
Confirm the order
Dispatch the order
After receiving the order request, condition checks are performed to check if it is normal or
special order. After the type of order is identified, dispatch activity is performed and that is
marked as the termination of the process.
WHERE TO USE ACTIVITY DIAGRAMS?
The basic usage of activity diagram is similar to other four UML diagrams. The specific
usage is to model the control flow from one activity to another. This control flow does
not include messages.
Activity diagram is suitable for modeling the activity flow of the system. An application
can have multiple systems. Activity diagram also captures these systems and describes
the flow from one system to another. This specific usage is not available in other
diagrams. These systems can be database, external queues, or any other system.
We will now look into the practical applications of the activity diagram. From the above
discussion, it is clear that an activity diagram is drawn from a very high level. So it gives
high level view of a system. This high level view is mainly for business users or any
other person who is not a technical person.
This diagram is used to model the activities which are nothing but business
requirements. The diagram has more impact on business understanding rather
than on implementation details.
Activity diagram can be used for −
Modeling work flow by using activities.
Modeling business requirements.
High level understanding of the system's functionalities.
Investigating business requirements at a later stage.