0% found this document useful (0 votes)
22 views

Oosd Notes Unit3

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Oosd Notes Unit3

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

UNIT-3

BENEFITS OF OBJECT ORIENTED MODELING :--


There are several advantages and benefits of object oriented modeling. Reuse and emphasis on quality are the major
highlights of OOM. OOM provides resistance to change, encapsulation and abstraction, etc. Due to its very nature, all these
features add to the systems development:
• Faster development
• Increased Quality
• Easier maintenance
• Reuse of software and designs, frameworks
• Reduced development risks for complex systems integration.

Overview of object design

Object-oriented analysis, design and programming are related but distinct.


OOA is concerned with developing an object model of the application domain.
OOD is concerned with developing an object-oriented system model to implement
requirements.
OOP is concerned with realising an OOD using an OO programming language such as Java or
C++.

Characteristics of OOD
Objects are abstractions of real-world or system entities and manage themselves.
Objects are independent and encapsulate state and representation information.
System functionality is expressed in terms of object services.
Shared data areas are eliminated.
Objects communicate by message passing.
Objects may be distributed and may execute sequentially or in parallel.

Advantages of OOD
Easier maintenance. Objects may be understood as stand-alone entities.
Objects are potentially reusable components.
For some systems, there may be an obvious mapping from real world entities to system objects.

Object Design
The object design phase comes after the analysis and system design. The object design phase adds
implementation details such as restructuring classes for efficiency, internal data structures and algorithms to
implement operations, implementation of control, implementation of associations and packaging into physical
modules. Object design extends the analysis.
The object design phase determines the full definitions of the classes and associations used in the
implementation, as well as the interfaces and algorithms of the methods used to implement operations. The
object design phase adds internal objects for implementation and optimizes data structures and algorithms.

there are three models that define the operations on classes:


1) Object model: This describes the classes of objects in the system, including their attributes, and the
operations that they support. The analysis object model information definitely exists in some form in design.
For this, sometimes new redundant classes are added which increase efficiency.
2) Functional model: This defines the operation that the system must implement. For each operation, from the
analysis model must be assigned an algorithms that implements clearly and efficiently, according to the
optimization goals selected during system design. In this model, we map the logical structure of the analysis
model into a physical organization of a program.
3) Dynamic model: The dynamic model describes how the system responds to external events. The
implementation of control of flow in a program must be realized either explicitly or implicitly. Explicit means
by the internal scheduler that recognizes events and map them into operation calls. Implicit means by choosing
algorithms that perform the operations in a specified order.

OBJECT DESIGN STEPS:→ Object design is a very iterative process in which several classes (maybe
newly created), relationships between objects, are added when you move from one level to another level of
the design.

There are certain steps to be followed in this design:


1) Classify the operations on classes:→ This step basically means all the three models, functional, object
and dynamic (studied in last section) must be combined so as to know what operations are to be performed
on objects.

We can make a state diagram describing the life history of an object. A transition is a change of state of
object and it maps into an operation on the object. It helps in visualizing state changes. We can associate an
operation with each event received by an object. Also, sometimes an event may represent an operation on
another objects i.e., where one event triggers another event. Thus, in this case, the event pair must be
mapped into an operation performing action and returning control, provided that the events are on a single
thread of control passing from object to object. Any action initiated by transition in a state diagram can be
expanded into an entire data flow diagram in the functional model. The processes in a data flow diagram
consist of sub-operations which may be operational on the original target object, or on other objects.

We can determine the target object of a sub-operation as follows:


i) If the process extracts a value from I/P flow=> input, flow is target.
ii) If the process has the same type of input and output flow and O/P value is the updated
version of I/P => I/O, flow is target.
iii) If the process has an I/P from or an O/P to a data source => data, source is a target of the
process.
iv) If the process constructs O/P value from a number of inputs => operation is class operation
on the output class. 2
2) Design an algorithm to implement operations Each and every operation specified in a functional
model should be formulated as an algorithm. The algorithm indicates how the operation is done rather than
what it does, as in analysis specification.
The algorithm designer must:
i) Select the proper algorithm so as to minimize implementation cost
ii) Find the most appropriate data structure for the selected algorithm
iii) Define new internal classes and operations, if required
iv) Assign responsibility for operations to appropriate classes.
3) Optimization of data access paths Optimization is a very important aspect of any design. The designer
should do the followings for optimization:
i) Add redundant associations, or omit non-usable existing associations to minimize access cost
and maximize convenience
ii) Rearrange the order of computational tasks for better efficiency
iii) Save derived attributes to avoid re-computation of complicated expressions
4) Implementing software control To implement software control the designer must redesign the strategy
of the state event model that is present in the dynamic model. Generally, there are three basic approaches to
implement the dynamic model.
These approaches are:
i) Storing state of program as location within a program, i.e., as a procedure driven system
ii) Direct implementation of a state machine mechanism i.e., event driver
iii) Using concurrent tasks.
5) Adjustment of inheritance The inheritance can be increased as the object design progresses by
changing the class structure.
The designer should:
i) Adjust, or rearrange the classes and operations
ii) Abstract common behavior out of groups of classes
iii) Use delegation to share behavior when inheritance is semantically incorrect.

6) Design of associations During the object design phase we must make a strategy to implement the
associations. Association can be unidirectional or bi-directional. Whichever implementation strategy we
choose, we should hide the implementation, using access operations to traverse and update the associations.
This will allow us to change our decision with minimal effort. The designer should:
i) Analyze the path of associations.
ii) Implement every association either as a distinct object, or as a link to another object.

7) Determine object representation As a designer, you must choose properly when to use primitive types
in representing objects, and when to combine groups of related objects, i.e., what is the exact representation
of object attributes.

8) Package classes and associations into models Programs are made of discrete physical units that can be
edited, complied, imported or otherwise manipulated. The careful partitioning of an implementation into
package is important for group work on a program. Packaging involves the following issues:
a. Information hiding
b. Collection of entities
c. Constructing physical modules with strong coupling within each module.

CHOOSING ALGORITHMS
In general, most of the operations are simple and have a satisfactory algorithm because the description of what is to be
done also indicates how it is to be done. Most of the operations in the object link network simply traverse to retrieve or
change attributes or links. Non-trivial algorithms are generally required for two reasons:
i) If no procedural specification is given for functions
ii) If a simple, but inefficient algorithm serves as a definition of function.

There are a number of metrics for selecting best algorithm:


i) Computational complexity: This refers to efficiency. The processor time increases as a function of the size of the data
structure. But small factors of inefficiency are insignificant if they improve the clarity.
ii) Ease of use: A simple algorithm, which is easy to implement and understand, can be used for not very important
operations.
iii) Flexibility: The fully optimized algorithm is generally less readable and very difficult to implement. The solution for
this is to provide two implementations of crucial operations:
• A complicated but very efficient algorithm
• A simple but inefficient algorithm.
Now, let us see the basic activities that are involved in algorithm selection and expression
Selecting Data Structure
Algorithms work on data structure. Thus, selection of the best algorithm means selecting the best data structure. The data
structures never add any information to the analysis model, but they organize it in a form that is convenient for the
algorithms that uses it. Many such data structure include arrays, lists, stacks, queues, trees, etc. Some variations on these
data structures are priority queues, binary trees, etc. Most object oriented languages provide various sets of generic data
structures as part of their predefined class libraries.
Defining Internal Classes and Operations
When we expand algorithms, new classes can be added to store intermediate results. A complex operation can be looked at
as a collection of several lower level operations i.e., a high level operation is broken into several low level operations.
These lower level operations should be defined during the design phase.
Assigning Responsibility for Operation
Many operations may have obvious target objects, but some of these operations can be used at several places in an
algorithm, by one of several objects. These operations are complex high level operations which may be overlooked in
laying out object classes as they are not an inherent part of any one class.

DESIGN OPTIMIZATION
The inefficient but correct analysis model can be optimized to make implementation more efficient. To optimize the
design, the following things should be done:
a) Adding Redundant Associations for Efficient Access
Redundant associations do not add any information, thus during design we should actually examine the structure of object
model for implementation, and try to establish whether we can optimize critical parts of the completed system. Can new
associations be added, or old associations be removed? The derived association need not to add any information to the
network, they help increasing the model information in efficient manner.
We can analyze the use of paths in the association network as follows:
• Evaluate each operation
• Find associations that it must pass through to get information. Associations can be bi-directional (generally by more than
one operation), or unidirectional, which can be implemented as pointers.

For each operation, we should know the followings:


• How frequently is the operation needed, and how much will it cost?
• What is the fan-out along a path through the network? To find fan-out of the complete path, multiply the average count of
each “many” associations found in the path with individual fan-outs.
• What are the objects that satisfy the selection criteria (if specified) and are operated on? When most of the objects are
rejected during traversal for some reason, then a simple nested loop may be inefficient at finding target objects.
b) Rearranging the Execution Order for Efficiency
As we already know algorithm and data structure are closely related to each other, but data structure is considered as the
smallest but very important part of algorithm. Thus, after optimizing the data structure, we try to optimize the algorithm
itself.
In general, algorithm optimization is achieved by removing dead paths as early as possible. For this, we sometimes reverse
the execution order of the loop from the original functional model.
c) Saving Derived Attributes to Avoid Recomputation
Data which is derived from other data should be stored in computed form to avoid re-computation. For this, we can define
new classes and objects, and obviously, these derived classes must be updated if any base object is changed.

Packaging Classes
In any large project, meticulous partitioning of an implementation into modules or packages is important.
During object design, classes and objects are grouped into packages to enable multiple groups to work
cooperatively on a project.
The different aspects of packaging are −
• Hiding Internal Information from Outside View − It allows a class to be viewed as a “black box” and
permits class implementation to be changed without requiring any clients of the class to modify code.
• Coherence of Elements − An element, such as a class, an operation, or a module, is coherent if it is
organized on a consistent plan and all its parts are intrinsically related so that they serve a common goal.
• Construction of Physical Modules − The following guidelines help while constructing physical
modules −
o Classes in a module should represent similar things or components in the same composite object.
o Closely connected classes should be in the same module.
o Unconnected or weakly connected classes should be placed in separate modules.
o Modules should have good cohesion, i.e., high cooperation among its components.
o A module should have low coupling with other modules, i.e., interaction or interdependence
between modules should be minimum.
ADJUSTMENT OF INHERITANCE
During object design, inheritance is readjusted by rearranging classes and operations, and abstracting common behavior.
Rearranging Classes and Operations
The different, yet similar, operation of different classes can be slightly modified so that they can be covered by a single
inherited operation. The chances of inheritance can be increased by the following kind of adjustments:
i) Some operations needs less arguments than other similar operations, like drawing an object, e.g., circle, rectangle, etc.,
with, or without, color fill. Thus, the attribute color can be accepted, or ignored for consistency with color displays.
ii) Some operations need less argument than other, because they are special case of general arguments. Thus, varied newer
operation can be implemented by calling general operation and new argument values. For example, insertion in the
beginning or end of the list are special cases of insertion in the list.
iii) Different classes can have similar attributes, but different names. Thus, they can be combined and placed in the base
class so that the operation to access the attribute may match in different classes.
iv) Sometimes an operation is required by a subset of classes. In this case, declare the operation in base class, and all those
derived classes that do not need it can be declared as no-operation.

JSD, Jackson Structure Design is a methodology to specify and design systems in which time factor is
significant and system may be described using sequence of events. Developed by Michael A. Jackson , this
design method considers the fact that the design of the system is an extension of the programme design. The
purpose of this design method is to create a maintainable software. The method addresses all stages of the
software development life cycle. It has three phases:
1. Modeling phase - A JSD model starts with real world consideration. This phase is a part of analysis
process. The aspects of the real world relevant to the system being developed are modeled in this phase.
2. Specification phase - This phase focuses on the specification. In this phase JSD determines what is to be
done? The previous phase i.e. the modeling phase provides the basic for the system specifications to
achieve the required functionality.
3. implementation phase - In this phase , JSD determines how to achieve required functionality.
Operational specifications are executed so that it expresses desired system behavior in terms of some
abstract machine.

Ways of working

• The basic principle of operation of JSD is that development must start with describing and modeling the
real world rather than specifying the function performed by the system.
• The second principle states that an adequate model of a time ordered world must itself be time ordered.
The aim is to map progress in the real world on progress in the system that models it.
• The third principle stetes way of implementing the system based on transformation of specification in to
efficient set of processes. These processes should be designed in a manner to make them run on
available software and hardware.

Steps for JSD software development

Originally presented by Jackson in 1983 the method consisted of six steps which are following.
1. Entity /action step
2. Entity structure step
3. Initial model step
4. function step
5. system timing step
6. system implementing step
Later , some steps were combined to create a method with only three steps
1. Modeling stage (Analysis)
o Action step
o Structure step
2. Network stage (design)
o Initial model step
o Function step
o System timing step
3. Implementation stage (Realisation)
o System implementation step

Advantages of JSD
1. specially designed to handle real time problem.
2. JSD considers concurrent processing and timing.
3. JSD modeling focuses on time.
4. It provide functionality in the real world.
5. Excellent methodology for micro code application.

Disadvantages of JSD

1. JSD is a poor approach for high level analysis and data base design.
2. More complex due to pseudo code representation.
3. complex and difficult to understand.
4. less graphically oriented than SA/ SD and OMT.

Structured Analysis vs. Object Oriented Analysis

The Structured Analysis/Structured Design (SASD) approach is the traditional approach of software
development based upon the waterfall model. The phases of development of a system using SASD are −

• Feasibility Study
• Requirement Analysis and Specification
• System Design
• Implementation
• Post-implementation Review
Now, we will look at the relative advantages and disadvantages of structured analysis approach and object-
oriented analysis approach.
Advantages/Disadvantages of Object Oriented Analysis
Advantages Disadvantages

Focuses on data rather than the procedures as Functionality is restricted within objects. This may pose a
in Structured Analysis. problem for systems which are intrinsically procedural or
computational in nature.

The principles of encapsulation and data hiding It cannot identify which objects would generate an optimal
help the developer to develop systems that system design.
cannot be tampered by other parts of the
system.

The principles of encapsulation and data hiding The object-oriented models do not easily show the
help the developer to develop systems that communications between the objects in the system.
cannot be tampered by other parts of the
system.

It allows effective management of software All the interfaces between the objects cannot be represented in
complexity by the virtue of modularity. a single diagram.

It can be upgraded from small to large systems


at a greater ease than in systems following
structured analysis.

Advantages/Disadvantages of Structured Analysis


Advantages Disadvantages

As it follows a top-down approach in contrast to In traditional structured analysis models,


bottom-up approach of object-oriented analysis, it one phase should be completed before the
can be more easily comprehended than OOA. next phase. This poses a problem in
design, particularly if errors crop up or
requirements change.

It is based upon functionality. The overall purpose is The initial cost of constructing the system
identified and then functional decomposition is done is high, since the whole system needs to
for developing the software. The emphasis not only be designed at once leaving very little
gives a better understanding of the system but also option to add functionality later.
generates more complete systems.

The specifications in it are written in simple English It does not support reusability of code. So,
language, and hence can be more easily analyzed the time and cost of development is
by non-technical personnel. inherently high.

SR. SA/SD OMT


No.
1 It manages a system around It manages system around real world objects.
procedures.
2 More importance is on functional More importance is on object model and less on
model and less on object model. functional model.
3 Dominance order is functional, Dominance order is object, dynamic and functional.
dynamic and object.
4 It is a historical approach. It is much advanced approach.
5 It clearly marks the system boundaries System boundries can be easily extending by adding
across which software procedures new objects, relationships.
should communicate with real world.
It is difficult to extend boundries.
6 Decomposition of process to sub- Decompsition is based on objects so different
process is not standardized. Different people provide similar decomposition.
people provide different
decomposition.
7 Reusability of components across Reusablity of components across projects is more as
projects is less as compared to in compared to SA/AD.
OMT.
8 Not easily modifiable and extensible. Easily modifiable and extensible.
9 Used when functions are more Used when data is more important than functions.
important than data.
10 Difficult to merge programming code It better integrates data with programming code as
organized about functions while database is organized around data.
database is organized around data.

Data abstraction is one of the most essential and important feature of object oriented programming in C++.
Abstraction means displaying only essential information and hiding the details. Data abstraction refers to
providing only essential information about the data to the outside world, hiding the background details or
implementation.
Consider a real life example of a man driving a car. The man only knows that pressing the accelerators will
increase the speed of car or applying brakes will stop the car but he does not know about how on pressing
accelerator the speed is actually increasing, he does not know about the inner mechanism of the car or the
implementation of accelerator, brakes etc in the car.
Advantages of Data Abstraction:
• Helps the user to avoid writing the low level code
• Avoids code duplication and increases reusability.
• Can change internal implementation of class independently without affecting the user.
• Helps to increase security of an application or program as only important details are provided to the user.

Data encapsulation is a mechanism of bundling the data, and the functions that use them and data
abstraction is a mechanism of exposing only the interfaces and hiding the implementation details from the
user.
Encapsulation is an Object Oriented Programming concept that binds together the data and functions that
manipulate the data, and that keeps both safe from outside interference and misuse. Data encapsulation led to
the important OOP concept of data hiding.

You might also like