Unit 2
Unit 2
2.0 INTRODUCTION
Object oriented analysis (OOA) is concerned with developing software engineering
requirements and specifications that expressed as a system’s object model composed
of a population of interacting objects. The concept of abstraction in object oriented
analysis (OOA) is important. Abstraction may be defined as: the characteristics of an
object which make it unique and reflect an important concept. Analysis is a broad
term, best qualified, as in requirements analysis (an investigation of the requirements)
or object oriented analysis (an investigation of the objects of the problem domain).
OOA views the world as objects with data structures and behaviors and events that
trigger operations, for object behavior changes. The idea is to see system as a
population of interacting objects, each of which is an atomic bundle of data and
functionality, (the foundation of object technology) and provides an attractive
alternative for the development of complex systems.
The problem statement is important for any analysis. It is a general description of the
user’s difficulties, and desires. The purpose of problem statement is to identify the
general domain in which you will be working.
In this Unit you will study various analysis techniques: object modeling, dynamic
modeling and functional modeling. You will also learn how add operations in system
and how to do refining of the analysis model.
2.1 OBJECTIVES
After going through this unit, you should be able to:
• define the concepts of the objects in the system;
• express required system behaviour in terms of business objects in the system,
and actions that the user can perform on them;
• understand how to define and analyze the problem statement;
• explain the purpose of object modeling;
• explain dynamic modeling;
• describe the event flow between objects and how to draw state diagrams of real
world problems;
• explain and understand the importance of functional model;
• explain how operations can be added in various analysis techniques, and
• explain the importance of iterating or refining the analysis model.
21
Object Oriented
Modeling and UML 2.2 OBJECT ORIENTED ANALYSIS
In this section we will discuss basics of object oriented analysis with the help of object
oriented features.
Analysis
Analysis is not a solution of the problem. Let us see what actually object oriented
(OO) analysis. Analysis emphasizes an investigation of the problem and
requirements, for example, if a new online trading system is desired by a trader, there
may be questions such as, how will it be used? What are its functions?
If you start a project the first question about that project’ will be how do we get
started? Where do we begin?
The starting point for object oriented analysis is to identify candidate objects and their
relationships.
The first stage can be a simple brain-storming of the possible objects. Then one
method is to go through all the nouns in any documentation about the world you are
analysing, and considering these as candidate objects of the system. Also, you can use
the alternative technologies for developing software engineering requirements and
specifications that include functional decomposition, essential systems analysis, and
structured analysis.
The Process of Development
The approach to development can be an iterative one. It involves repeated refinement
of the object model. The process needs to be controlled by an appropriate project
management process, involving reviews and check pointing at the levels of:
• Analysis
• Design
• Implementation
• Post Implementation Review
Object Orientation and Analysis
An Object is something that exists within the problem domain that can be identified
by data and/or behaviour. An example of an object is a car. The data of a car could be
the wheel, brake, seat, etc. The behaviour of the car would be to drive on roads, its
speed, etc.
Object oriented analysis is the concept which actually forces you to think in terms of
the application domain when its behaviour and data known to you.
In OOA the primary focus on identifying objects from the application domain, then
fitting procedures around them.
For example, in the case of the flight information system, the objects would include
Plane, Flight, and Pilot, etc.
The object model has many aspects, which are associated with OO concepts.
Now we will discuss the following principle of OO.
Abstraction, Encapsulation, Identity, Modularity, Hierarchy,
Typing, Concurrency, and Persistence
Abstraction
You understand the term object. Now, let us see how problems are seen as objects,
and find their associated data and behaviour. You will notice that an object is a real
life entity, or abstraction.
22
Object Oriented Analysis
In our daily life we deal with complexity by abstracting details away.
Let us see this with an example of:
Driving a car does not require knowledge of internal combustion engine. It is
sufficient to think of a car as simple transport.
In simple term, abstraction means to focus on the essential, inherent aspects of an
entity, ignoring its accidental properties. Abstraction is a normal process that we do
everyday. When you view the world, you can not possibly take in every minute detail,
so you concentrate on the aspects that are important.
An abstraction is a simplified description of a system that captures the essential
elements of that system (from the perspective of the needs of the modeler), while
suppressing all other elements.
Encapsulation
This separates the interface of an abstraction from its implementation. Taking the
above example of a car, we can now categorize as:
Abstraction Car
Interface Steering, pedals, controls
Implementation Generally, you don’t know
Encapsulation also means data hiding, which consists of separating the external
aspects of an object, which are accessible to other objects.
Now let us take a example of the Stack.
A Stack abstraction provides methods like push (), pop (), isEmpty(), isFull(). The
Stack can be implemented as a singly linked list, or a doubly linked list, or an array, or
a binary search tree. This feature is called encapsulation. It hides the details of the
implementation of an object.
The Benefits of Encapsulation
To hide the details of a class, you can declare that data or implementation in its private
part so that any other class clients will not be able to know about. It will have the
ability to change the representation of an abstraction (data structures, algorithms)
without disturbing any of its clients. The major benefit of encapsulation is that you.
By Encapsulation
You can delay the resolution of the details until after the design.
Keep your code modular.
Object Identity
Object identity is a property of an object that distinguishes the objects from all other
objects in the applications. With object identity, objects can contain, or refer to other
objects. You can create an object identity in three ways:
1) You can refer as memory address in programming languages.
In a complete object oriented system each object is given an identity that will be
permanently associated with the object irrespective of the object’s structural or state
transitions. The identity of an object is also independent of the location, or address of
the object. Object identity provides the most natural modeling primitive to allow the
“same object to be a sub-object of multiple parent objects”.
23
Object Oriented Modularity
Modeling and UML
Modularity is closely tied to encapsulation; you may think of modularity as a way of
mapping encapsulated abstractions into real, physical modules. It is a property of a
system that has been decomposed into cohesive and loosely coupled modules.
Cohesion and coupling gives two goals for defining modules. You should make a
module cohesive (shared data structures, similar classes) with an interface that allows
for minimal inter-module coupling.
It is important to remember that the decisions concerning modularity are more
physical issues, whereas the encapsulation of abstractions is logical issues of design.
Hierarchy
This is ranking or ordering of abstraction.
Hierarchy is decided by using the principle of ‘divide and conquer’. You can describe
complex objects in terms of simpler objects. This is the property of object oriented
analysis (OOA) which enables you to reuse the code.
You can place an existing class directly inside a new class. The new class can be made
up of any number and type of other objects, in any combination that is needed to
achieve the desired functionality. This concept is called composition (or more
generally, aggregation). Composition is often referred to as a “has-a” relationship or
“part-of” relationship, for example, in “automobile has an engine” or “engine is part
of the automobile.”
Typing
This enforces object class such that objects of different classes may not be
interchanged. In other words, class can be visualized as a type. Remember that there
are two kinds of typing. This typing does not mean the way you usually type the
letters.
Strong Typing: When any operation upon an object (which is defined) can be
checked at compile time, i.e., type is confirmed forcefully.
Weak Typing: Here, operations on any object can be performed, and you can send
any message to any class. Type confirmation is not essential, but in these type of
language more errors at execution time may occur.
Concurrency
The fundamental concept in computer programming is the idea of handling more than
one task at a time. Many programming problems require that the program be able to:
1) Stop what it’s doing
2) Currently deal with some other problem, and
3) Return to the main process. There is a large class of problems in which you
have to partition the problem into separately running pieces so that the whole
program can be more responsive. Within a program, these separately running
pieces are called threads, and the general concept is called multithreading.
Currently, if you have more than one thread running that is expecting to access the
same resource then there is a problem. To avoid this problem, a thread locks a
resource, completes its task, and then releases the lock so that someone else can use
the resource. It can lock the memory of any object so that only one thread can use it at
a time. It is important to handle concurrent running programs/threads properly.
Persistance
When you create an object, it exists for as long as you need it, but under no
circumstances do object exist when the program terminates. While this makes sense at
first, there are situations in which it would be incredibly useful if an object could exist
24
Object Oriented Analysis
and hold its information even while the program is not running. When, next time you
start the program, the object would be there and it would have the same information it
had the previous time the program was running. Of course, you can get a similar effect
by writing the information to a file or to a database, but in the spirit of making
everything an object it would be quite convenient to be able to declare an object
persistent and have all the details taken care of for you.
It is important for an analyst to separate the true requirements from design and
implementation decisions.
Problem statement should not be incomplete, ambiguous, and inconsistent. Try to
state the requirements precisely, and to the point. Do not make it cumbersome.
Some requirements seem reasonable but do not work. These kind of requirements
should be identified. The purpose of the subsequent analysis is to fully understand the
problem and its implications, and to bring out the true intent of the Client.
……………………………………………………………………………………
….………………………………………………………………………………...
................................................................................................................................
2) Give an example of enforcement in Typing.
……………………………………………………………………………………
….………………………………………………………………………………...
……………………………………………………………………………………
3) What are the benefits of OOA technology?
……………………………………………………………………………………
….………………………………………………………………………………..
……………………………………………………………………………………
25
Object Oriented 4) Briefly explain what is to be done while defining the problem statement.
Modeling and UML
……………………………………………………………………………………
….……………………………………………………………………………...…
……………………………………………………………………………………
You are already familiar with structured analysis. Now, this is the appropriate time to
have a comparison of OOA and Structured analysis.
The object oriented (OO) analysis design itself does not provide support for
identifying which objects will generate an optimal system design. Specifically, there is
no single diagram that shows all of the interfaces between objects. You will study
object oriented analysis design (OOAD) diagrams in Unit 3 of this course. As you
know, coupling is a major factor in system complexity, not having this information
makes architecture component selection a hit or miss proposition.
Advantages and Disadvantages of Structured Analysis
With experience, you will come to know that most customers understand structured
methods better than object oriented (OO) methods. Since one of the main reasons of
modeling a system is for communication with customers and users, there is an
advantage in providing structured models for information exchange with user groups
or customers.
26
Object Oriented Analysis
In fact, specifications are typically in the form of a simple English language statement
of Work and Requirement Specification. Therefore, the system to be built, must be
understood in terms of requirements (functions the system must perform), that is why
this naturally leads to a structured analysis, at least at the top level. Specifically
structured methods (functional decomposition) provide a natural vehicle for
discussing, modeling, and deriving the requirements of the system.
The disadvantage with structured methods is that they do not readily support the use
of reusable modules. The top down process works well for new development, but does
not provide the mechanisms for “designing in” the use of existing components. The
top down process of functional decomposition does not lead to a set of requirements
which map well to existing components.
When the requirements do not map cleanly, you have two choices: either you do not
use the existing components, or force fit the requirements to the existing components
and “somehow” deal with the requirements which are only partially covered by the
existing components, which does not lead to a good successful system. Now, we will
discuss how actually object oriented analysis (OOA) system is performed.
Association relationship
Relationship name
One- to-many
many-to-many
One-to-one
Aggregation
Subtype
Connected to
Generally, a state diagrams allows you to further explore the operations and attributes
that need to be defined for an object. They consist of sets of states which an object is
in, and events which take the object from one state to another.
State: An object may have one or more states−stable points in its life, expressed by the
object’s attributes and relationships.
Statename A state
A transition
An initial State
A final state
Acquire Sell
In Library
Return Borrow
On Loan
Return
States may be seen as composite states: a collection of states treated as one state at a
higher level on analysis. In the example above, the state “In Library” is actually
composed of a sequence of sub-states which the library staff, if not borrowers would
need to know about.
Acquire
In Acquisitions
Classify
Withdraw
Withdrawn On Shelves
Reissue
Return Borrow
On Loan
Renew
Basically any system which you can reasonably model on a computer jumps from
state to state.
The level of state decomposition must be decided by judgement. A too fine grained
model is inappropriate; for example, modeling all the possible ages of an employee as
individual states. Also, a gross decomposition is useless; for example, modeling an
employee as employed or not.
You can ask whether all objects of world have behaviour which can be modeled.
Of course, not all objects have behavior worth modeling. Consider our example from
the field of object oriented nursery rhymes, the sad story of Humpty Dumpty. Clearly,
you would not like to model such trivial examples.
Basically you need to construct a state transition diagram for every object with
significant behaviour. You need not construct one for anything with trivial behaviour.
The reason for doing this is to identify further operations and attributes, to check the
logical consistency of the object and to more clearly specify its behaviour.
31
Object Oriented All the best notations can be used to describe the process they facilitate.
Modeling and UML
Now we have the basic ideas of object models and dynamic models, our approach to
analysis and design (so far) can be summarised as:
Describe Objects
Note: You should also match the events between state diagrams to verify consistency.
Till so far, you have been introduced to object modeling, and dynamic modeling.
Now, we will see what Function modeling is:
2.5.3 Functional Modeling
You know that Data flow modeling is a common technique used for the analysis of a
problem in software engineering. It is exceptionally useful for analyzing and
describing systems where there is a large amount of calculation involved.
Data flow models consist of a number of processes which exchange information. A
process transforms information it receives, and passes the transformed information on
to other processes or to objects in the system. Data flow models can be used to
uncover new operations and new attributes for the object model. Sometimes, new
objects can be discovered too.
Basically you can state that the functional model shows how values are computed. It
describes the decisions or object structure without the regard for sequencing.
It gives you dependency between the various data and the functions that relate them,
giving the flow of data.
Each process needs to be implemented as an operation in one or more of the objects.
Each data item arising from an object must have a corresponding attribute, or set of
attributes in the source object. The data flow diagram (DFD) corresponds to activities
or actions in the state diagrams of the classes.
That is why it is suggested to construct the functional model after the object and
dynamic models.
Now, let us discuss about the creation of the DFD and the functional model.
The approach to data flow diagramming should be as follows:
• Create a data flow diagram for each of the major outputs of the system
• Work back from the outputs to the inputs to construct the diagram
• Add new objects where necessary to the object model as you discover the need
for them in the data flow modeling add new operations and attributes to the
object model as you discover the need for them in the data flow modeling.
One thing you have to remember is that the data flow diagram is not used as a basis
for devising the structure of the system.
Steps in constructing a Functional Model
• Identify input and output values
• Build data flow diagrams showing functional dependencies
• Describe functions
• Identify constraints
• Specify optimisation criteria.
32
Object Oriented Analysis
Identifying Input and Output Values
First, identify what data is going to be used as input to the system, and what will be
the output from the system. Input and output values are parameters of events between
the system and the outside world. You must note that Input events that only affect the
flow of control, such as cancel, terminate, or continue. They do not supply input
values. For example, supplier code, name, product description, rate per unit, etc. are
the inputs to a sales system.
Build data Flow diagrams showing functional dependencies
Data flow diagrams are useful for showing the functional dependencies. In data flow
diagrams processes are drawn as bubbles, each bubble containing with the name of the
process inside. Arrowhead lines are used to connect processes to each other, and to
objects in the system. The lines are label with the information that is being passed.
Objects are drawn as rectangular boxes, just as in the object model, but usually with
just the name of these objects and not the attributes and operations.
Figure 7: Some objects in figure 7: a simple DFD is given for sales system
Sales
Total Deliveries
Product Price Product
Calculate order
line basic cost
Product VAT Rate
Calculate order
Customer
line discount
Line Total
Customer
Product Discount
Discounted Line
Quantity Total
Discount Rate Calculate
Total
invoice
Calculate
Quantity
Discount Discount and invoice Final
Total
34
Object Oriented Analysis
Accessing from one object to another through the object model can be referred to as
“pseudo-attribute” like Account.Bank, where account and bank are two separate
objects of their respective classes.
Operations from events
During analysis, events which are sent to the target objects. An operation on the object
are presented as labels on transitions and should not be explicitly listed in the object
model.
Events can be expressed as explicit methods.
You can also implement events by including event handler as part of the system
substrate.
Operations from State Action and Activities
You must see that State actions and activities are actually functions, which can be
defined as the operations on the object model.
Operations from Functions
As you know, function are actually operations on object. These
functions should be simple and summarized on the object model. Organise the
functions into operations on objects. For example, the select operations are really path
traversals in the object model. The operations like withdrawal-money, verify-
password are the operations on class Account of Bank Management system.
You can write as:
account: withdraw (code, amount)->status
account: deposit (code, amount)->status.
35
Object Oriented
Modeling and UML 2.7 ANALYSIS ITERATION
To understand any problem properly you have to repeat the task which implies that
analysis requires repetition. First, just get the overview of the problem, make a rough
draft, and then, iterate the analysis according to your understanding. Finally, you
should verify the final analysis with the client or application domain experts. During
the iteration processes refining analysis and restating of requirement takes place.
2.7.1 Refining the Ratio Analysis
Basically, refinement leads to purity. So to get a cleaner, more understandable and
coherent design, you need to iterate the analysis process.
2.8 SUMMARY
In this Unit you have learned that the goal of analysis is to understand the problem
and the application domain, so that you come out with a well cohesive design. There
is no end or border line between the analysis and the design phase in software
engineering. There are three objectives of the analysis model:
Object oriented analysis (OOA) describes what the customer requires, it establishes as
basis for the creation of a software design, and it defines a set of requirements that can
be validated.
You also remember that the requirement analysis should be designed in such a way
that it should tell you what to be done, not how it is implemented.
The object model is the principal output of an analysis and design process.
Dynamic modeling is elaborated further by adding the concept of time: new attributes
are computed as a function of attribute changes over time. In this unit, after defining
the scenario of typical and exceptional sessions, identify events followed by the
building of state diagrams for each active object showing the patterns of events it
36
Object Oriented Analysis
receives and sends, together with actions that it performs. You should also match the
events between state diagrams to verify consistency.
You have learned that a functional model shows how values are computed; it
describes the decisions, or object structure without regard for sequencing.
It gives you dependency between the various data and the functions that relate them,
giving the flow of data. Here you construct the data flow diagram which interacts with
internal objects and serves as, data stores between iterations. You also specify the
required constraints, and the optimisation criteria.
You have seen that refining and restating will give you more clarity of the analytical
model of the system.
37
Object Oriented Different user classes may require different mental models of the objects in the
Modeling and UML system. This includes:
What type of objects there are (user objects).
What information the user can know about an object of a particular type (user
object attributes).
How the objects may be related to other objects (relationships).
Object types with ‘subtypes’ which have additional specialised actions or
attributes, i.e., User object, Container objects, User object action, User object
subtype.
A model of the business objects which end users believe interact with in a GUI
system.
Pick Up
Put Down
Ring in
On Hook On Hook Pick up Off Hook Hung up on Off Hook
Inactive Ringing Connected Inactive
Time Out
Pick Up
Off Hook
Ringing Ringing
Tone Out
38