Unit-3
Unit-3
Unit-3
Identifying objects
Organizing the objects by creating object model diagram
Defining the internals of the objects, or object attributes
Defining the behavior of the objects, i.e., object actions
Describing how the objects interact
The common models used in OOA are use cases and object models.
Object-Oriented Design
Object–Oriented Design (OOD) involves implementation of the conceptual model
produced during object-oriented analysis. In OOD, concepts in the analysis model,
which are technology−independent, are mapped onto implementing classes,
constraints are identified and interfaces are designed, resulting in a model for the
solution domain, i.e., a detailed description of how the system is to be built on concrete
technologies.
The implementation details generally include −
Object-Oriented Design
The analysis phase identifies the objects, their relationship, and behavior using the
conceptual model.
While in design phase, we describe these objects (by creating class diagram from
analysis. But, analysis and design may occur in parallel, and the results of one activity
After the analysis phase, the conceptual model is developed further into an object-
oriented model using object-oriented design (OOD). In OOD, the technology-
independent concepts in the analysis model are mapped onto implementing classes,
constraints are identified, and interfaces are designed, resulting in a model for the
solution domain.
In a nutshell, a detailed description is constructed specifying how the system is to be
built on concrete technologies.
The stages for object–oriented design can be identified as −
Definition of the context of the system
Designing system architecture
Identification of the objects in the system
Construction of design models
Specification of object interfaces
System Design
Object-oriented system design involves defining the context of a system followed by
designing the architecture of the system.
Context − The context of a system has a static and a dynamic part. The static
context of the system is designed using a simple block diagram of the whole
system which is expanded into a hierarchy of subsystems. The subsystem
model is represented by UML packages. The dynamic context describes how
the system interacts with its environment. It is modelled using use case
diagrams.
System Architecture − The system architecture is designed on the basis of the
context of the system in accordance with the principles of architectural design as
well as domain knowledge. Typically, a system is partitioned into layers and
each layer is decomposed to form the subsystems.
Object-Oriented Decomposition
Decomposition means dividing a large complex system into a hierarchy of smaller
components with lesser complexities, on the principles of divide–and–conquer. Each
major component of the system is called a subsystem. Object-oriented decomposition
identifies individual autonomous objects in a system and the communication among
these objects.
The advantages of decomposition are −
The individual components are of lesser complexity, and so more
understandable and manageable.
It enables division of workforce having specialized skills.
It allows subsystems to be replaced or modified without affecting other
subsystems.
Identifying Concurrency
Concurrency allows more than one objects to receive events at the same time and
more than one activity to be executed simultaneously. Concurrency is identified and
represented in the dynamic model.
Object Design
After the hierarchy of subsystems has been developed, the objects in the system are
identified and their details are designed. Here, the designer details out the strategy
chosen during the system design. The emphasis shifts from application domain
concepts toward computer concepts. The objects identified during analysis are etched
out for implementation with an aim to minimize execution time, memory consumption,
and overall cost.
Object design includes the following phases −
Object identification
Object representation, i.e., construction of design models
Classification of operations
Algorithm design
Design of relationships
Implementation of control for external interactions
Package classes and associations into modules
Object Identification
The first step of object design is object identification. The objects identified in the
object–oriented analysis phases are grouped into classes and refined so that they are
suitable for actual implementation.
The functions of this stage are −
Identifying and refining the classes in each subsystem or package
Defining the links and associations between the classes
Designing the hierarchical associations among the classes, i.e., the
generalization/specialization and inheritances
Designing aggregations
Object Representation
Once the classes are identified, they need to be represented using object modelling
techniques. This stage essentially involves constructing UML diagrams.
There are two types of design models that need to be produced −
Static Models − To describe the static structure of a system using class
diagrams and object diagrams.
Dynamic Models − To describe the dynamic structure of a system and show the
interaction between classes using interaction diagrams and state–chart
diagrams.
Classification of Operations
In this step, the operation to be performed on objects are defined by combining the
three models developed in the OOA phase, namely, object model, dynamic model, and
functional model. An operation specifies what is to be done and not how it should be
done.
The following tasks are performed regarding operations −
The state transition diagram of each object in the system is developed.
Operations are defined for the events received by the objects.
Cases in which one event triggers other events in same or different objects are
identified.
The sub–operations within the actions are identified.
The main actions are expanded to data flow diagrams.
Algorithm Design
The operations in the objects are defined using algorithms. An algorithm is a stepwise
procedure that solves the problem laid down in an operation. Algorithms focus on how
it is to be done.
There may be more than one algorithm corresponding to a given operation. Once the
alternative algorithms are identified, the optimal algorithm is selected for the given
problem domain. The metrics for choosing the optimal algorithm are −
Computational Complexity − Complexity determines the efficiency of an
algorithm in terms of computation time and memory requirements.
Flexibility − Flexibility determines whether the chosen algorithm can be
implemented suitably, without loss of appropriateness in various environments.
Understandability − This determines whether the chosen algorithm is easy to
understand and implement.
Design of Relationships
The strategy to implement the relationships needs to be chalked out during the object
design phase. The main relationships that are addressed comprise of associations,
aggregations, and inheritances.
The designer should do the following regarding associations −
Identify whether an association is unidirectional or bidirectional.
Analyze the path of associations and update them if necessary.
Implement the associations as a distinct object, in case of many–to-many
relationships; or as a link to other object in case of one–to-one or one–to-many
relationships.
Regarding inheritances, the designer should do the following −
Adjust the classes and their associations.
Identify abstract classes.
Make provisions so that behaviors are shared when needed.
Implementation of Control
The object designer may incorporate refinements in the strategy of the state–chart
model. In system design, a basic strategy for realizing the dynamic model is made.
During object design, this strategy is aptly embellished for appropriate implementation.
The approaches for implementation of the dynamic model are −
Represent State as a Location within a Program − This is the traditional
procedure-driven approach whereby the location of control defines the program
state. A finite state machine can be implemented as a program. A transition
forms an input statement, the main control path forms the sequence of
instructions, the branches form the conditions, and the backward paths form the
loops or iterations.
State Machine Engine − This approach directly represents a state machine
through a state machine engine class. This class executes the state machine
through a set of transitions and actions provided by the application.
Control as Concurrent Tasks − In this approach, an object is implemented as a
task in the programming language or the operating system. Here, an event is
implemented as an inter-task call. It preserves inherent concurrency of real
objects.
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.
Design Optimization
The analysis model captures the logical information about the system, while the design
model adds details to support efficient information access. Before a design is
implemented, it should be optimized so as to make the implementation more efficient.
The aim of optimization is to minimize the cost in terms of time, space, and other
metrics.
However, design optimization should not be excess, as ease of implementation,
maintainability, and extensibility are also important concerns. It is often seen that a
perfectly optimized design is more efficient but less readable and reusable. So the
designer must strike a balance between the two.
The various things that may be done for design optimization are −
Design Documentation
Documentation is an essential part of any software development process that records
the procedure of making the software. The design decisions need to be documented
for any non–trivial software system for transmitting the design to others.
Usage Areas
Though a secondary product, a good documentation is indispensable, particularly in
the following areas −
Contents
A beneficial documentation should essentially include the following contents −
High–level system architecture − Process diagrams and module diagrams
Key abstractions and mechanisms − Class diagrams and object diagrams.
Scenarios that illustrate the behavior of the main aspects − Behavioural
diagrams
Features
The features of a good documentation are −
Concise and at the same time, unambiguous, consistent, and complete
Traceable to the system’s requirement specifications
Well-structured
Diagrammatic instead of descriptive
Object Modeling Technique (OMT) is real world based modeling approach for
software modeling and designing. It was developed basically as a method to
develop object-oriented systems and to support object-oriented programming. It
describes the static structure of the system.
Object Modeling Technique is easy to draw and use. It is used in many
applications like telecommunication, transportation, compilers etc. It is also
used in many real world problems. OMT is one of the most popular object
oriented development techniques used now-a-days. OMT was developed
by James Rambaugh.
Purpose of Object Modeling Technique:
To test physical entity before construction of them.
To make communication easier with the customers.
To present information in an alternative way i.e. visualization.
To reduce the complexity of software.
To solve the real world problems.
Object Modeling Technique’s Models:
There are three main types of models that has been proposed by OMT:
1. Object Model:
Object Model encompasses the principles of abstraction, encapsulation,
modularity, hierarchy, typing, concurrency and persistence. Object Model
basically emphasizes on the object and class. Main concepts related with
Object Model are classes and their association with attributes. Predefined
relationships in object model are aggregation and generalization (multiple
inheritance).
2. Dynamic Model:
Dynamic Model involves states, events and state diagram (transition
diagram) on the model. Main concepts related with Dynamic Model are
states, transition between states and events to trigger the transitions.
Predefined relationships in object model are aggregation (concurrency) and
generalization.
3. Functional Model:
Functional Model focuses on the how data is flowing, where data is stored
and different processes. Main concepts involved in Functional Model are
data, data flow, data store, process and actors. Functional Model in OMT
describes the whole processes and actions with the help of data flow
diagram (DFD).
SA/SD VS OMT
Principles of Object-Oriented Systems
The conceptual framework of object–oriented systems is based upon the object model.
There are two categories of elements in an object-oriented system −
Major Elements − By major, it is meant that if a model does not have any one of these
elements, it ceases to be object oriented. The four major elements are −
Abstraction
Encapsulation
Modularity
Hierarchy
Minor Elements − By minor, it is meant that these elements are useful, but not
indispensable part of the object model. The three minor elements are −
Typing
Concurrency
Persistence
Abstraction
Abstraction means to focus on the essential features of an element or object in OOP,
ignoring its extraneous or accidental properties. The essential features are relative to
the context in which the object is being used.
Grady Booch has defined abstraction as follows −
“An abstraction denotes the essential characteristics of an object that distinguish it from
all other kinds of objects and thus provide crisply defined conceptual boundaries,
relative to the perspective of the viewer.”
Example − When a class Student is designed, the attributes enrolment_number,
name, course, and address are included while characteristics like pulse_rate and
size_of_shoe are eliminated, since they are irrelevant in the perspective of the
educational institution.
Encapsulation
Encapsulation is the process of binding both attributes and methods together within a
class. Through encapsulation, the internal details of a class can be hidden from
outside. The class has methods that provide user interfaces by which the services
provided by the class may be used.
Modularity
Modularity is the process of decomposing a problem (program) into a set of modules
so as to reduce the overall complexity of the problem. Booch has defined modularity as
−
“Modularity is the property of a system that has been decomposed into a set of
cohesive and loosely coupled modules.”
Modularity is intrinsically linked with encapsulation. Modularity can be visualized as a
way of mapping encapsulated abstractions into real, physical modules having high
cohesion within the modules and their inter–module interaction or coupling is low.
Hierarchy
In Grady Booch’s words, “Hierarchy is the ranking or ordering of abstraction”. Through
hierarchy, a system can be made up of interrelated subsystems, which can have their
own subsystems and so on until the smallest level components are reached. It uses
the principle of “divide and conquer”. Hierarchy allows code reusability.
The two types of hierarchies in OOA are −
“IS–A” hierarchy − It defines the hierarchical relationship in inheritance,
whereby from a super-class, a number of subclasses may be derived which may
again have subclasses and so on. For example, if we derive a class Rose from
a class Flower, we can say that a rose “is–a” flower.
“PART–OF” hierarchy − It defines the hierarchical relationship in aggregation
by which a class may be composed of other classes. For example, a flower is
composed of sepals, petals, stamens, and carpel. It can be said that a petal is a
“part–of” flower.
Typing
According to the theories of abstract data type, a type is a characterization of a set of
elements. In OOP, a class is visualized as a type having properties distinct from any
other types. Typing is the enforcement of the notion that an object is an instance of a
single class or type. It also enforces that objects of different types may not be generally
interchanged; and can be interchanged only in a very restricted manner if absolutely
required to do so.
The two types of typing are −
Strong Typing − Here, the operation on an object is checked at the time of
compilation, as in the programming language Eiffel.
Weak Typing − Here, messages may be sent to any class. The operation is
checked only at the time of execution, as in the programming language
Smalltalk.
Concurrency
Concurrency in operating systems allows performing multiple tasks or processes
simultaneously. When a single process exists in a system, it is said that there is a
single thread of control. However, most systems have multiple threads, some active,
some waiting for CPU, some suspended, and some terminated. Systems with multiple
CPUs inherently permit concurrent threads of control; but systems running on a single
CPU use appropriate algorithms to give equitable CPU time to the threads so as to
enable concurrency.
In an object-oriented environment, there are active and inactive objects. The active
objects have independent threads of control that can execute concurrently with threads
of other objects. The active objects synchronize with one another as well as with purely
sequential objects.
Persistence
An object occupies a memory space and exists for a particular period of time. In
traditional programming, the lifespan of an object was typically the lifespan of the
execution of the program that created it. In files or databases, the object lifespan is
longer than the duration of the process creating the object. This property by which an
object continues to exist even after its creator ceases to exist is known as persistence.
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
in Structured Analysis. may pose a 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
help the developer to develop systems that an optimal 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
help the developer to develop systems that the communications between the objects in the
cannot be tampered by other parts of the system.
system.
It allows effective management of software All the interfaces between the objects cannot be
complexity by the virtue of modularity. represented in a single diagram.
It is based upon functionality. The overall purpose is The initial cost of constructing the system is
identified and then functional decomposition is done high, since the whole system needs to be
for developing the software. The emphasis not only designed at once leaving very little option
gives a better understanding of the system but also 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.
Jackson Structure Design
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.
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.
It is another approach for object oriented design in which the time factor is the vital factor and is
described by using sequence of events. JSD is applicable to the application where efficiency
plays a vital role. JSD was introduced by Michael Jackson in 1983. The fundamental principle of
JSD[6] is that it focuses on describing the real world by the system i.e. its main focus is to map
the progress in the real world rather than specifying the functions performed by the system i.e its
main focus is to map the progress in the real world. JSD consist of three stages:
1. Modeling Stage – This Stage comprises of Entity Action and Entity Structure.
2. Network Stage – Initial model step, Function Step, and System Timing Step.
3. Implementation Stage – Implementation Step.
In modeling stage the entity structure diagram has been created and identifies the entities and
their actions. In a network phase a set of sequential is expanded into a process network by
addition of process for handling messages for external environment and generating system
output. In Entity Action the entities perform actions in time. The action is atomic and cannot
be decomposed further.
Entity Structure Step partially sequences the order of action with respect to time. In initial
model step we concentrate on state vector and data stream communication. A data stream is
an unbounded queue where read operator extracts the next record from the queue, if there are
no records when the process executing the read operation waits until the record is available
whereas in write operation data stream places the next record in the queue. In state vector we
are present all the possible states of an entity. Function step consist of pseudo code to the
output of action generated from states. In this step the developer requires a complete
specification of the system.
System Timing Step relates with the performance constraints of the system. The
implementation step focuses on process scheduling and allocates the number of processors
required. The process may be different form the processors. So it is the job of the developer
who decides how to get several processes to share the same processors.
Since JSD is useful for concurrent software, real time software and parallel programming
computers but when we talk about high level analysis JSD is ill suited. JSD approach is
difficult to understand because it is less graphical oriented as compared with SA/SD.
Since SA/SD and JSD both suffers from some limitations we will try to formulate a new
approach using cross over operation of genetic algorithm which can minimize the limitation
to a certain extent.
1. Issue of Books
2. Return of books
3. Join the membership.
4. Leave the membership.
5. Acquire the books.
6. Sell the books.
JSD approach for designing Library Management System : To design library
management system by JSD following stages should be taken
The library may require daily list of return of books. For each return event, each book
process writes a record on output stream R. These streams are merged with the
message D to generate another daily list. Then the function process F reads this
merged stream and whenever it encounters a D message daily list is produced.
Avoid it.
Flatten the class hierarchy.
Break out separate objects.
5 Implement method resolutions: Method resolution is one. Main features of
an object-oriented language that is lacking in a non-object-oriented language.
Method resolution can be implemented in a following ways
Avoid it.
Resolve methods at compile time.
Resolve methods at run time.
6. Implement associations: Implementing associations in a non-oriented
language can be done by:
Adding new data and function is Adding new data and function
not easy. is easy.
2 Approach In OOPs concept of objects and On other hand in case of POP the
classes is introduced and hence the main program is divided into
the program is divided into small small parts based on the
chunks called objects which are functions and is treated as
instances of classes. separate program for individual
smaller program.
4 Security Due to abstraction in OOPs data On other hand POP is less secure
hiding is possible and hence it is as compare to OOPs.
more secure than POP.
Sr. Key Object Oriented Programming Procedural Oriented
No. (OOP) Programming (POP)
Super Class: The class whose features are inherited is known as super
class(or a base class or a parent class).
Sub Class: The class that inherits the other class is known as sub class(or
a derived class, extended class, or child class). The subclass can add its
own fields and methods in addition to the superclass fields and methods.
Reusability: Inheritance supports the concept of “reusability”, i.e. when we
want to create a new class and there is already a class that includes some
of the code that we want, we can derive our new class from the existing
class. By doing this, we are reusing the fields and methods of the existing
class.
Types of Inheritance
There are Various types of inheritance in Java:
Single Inheritance:
In Single Inheritance one class extends another class (one class only).
In above diagram, Class B extends only Class A. Class A is a super class and
Class B is a Sub-class.
Multiple Inheritance:
In Multiple Inheritance, one class extending more than one class. Java does not
support multiple inheritance.
There are different ways in which parameter data can be passed into and out
of methods and functions. Let us assume that a function B() is called from
another function A(). In this case A is called the “caller function” and B is called
the “called function or callee function”. Also, the arguments which A sends
to B are called actual arguments and the parameters of B are called formal
arguments.
Types of parameters:
Formal Parameter : A variable and its type as they appear in the prototype of
the function or method.
Syntax:
function_name(datatype variable_name)
procedure double(x);
real x;
begin
x:=x*2
end;
In general, the effect of pass-by-name is to textually substitute the argument
in a procedure call for the corresponding parameter in the body of the
procedure.
Implications of Pass-by-Name mechanism:
The argument expression is re-evaluated each time the formal parameter
is passed.
The procedure can change the values of variables used in the argument
expression and hence change the expression’s value.