Ooad Module 1
Ooad Module 1
----------------------------------------------------------------------------------------------------------------------------- -------------------------------------------
UNIT-1
Introduction: The Structure of Complex systems, The Inherent Complexity of Software, Attributes
of Complex System, Organized and Disorganized Complexity, Bringing Order to Chaos, Designing
Complex Systems, Evolution of Object Model, Foundation of Object Model, Elements of Object
Model, Applying the Object Model.
Introduction: It’s a structured method for analyzing, designing a system by applying the object-
orientated concepts, and develop a set of graphical system models during the development life
cycle of the software.
OOAD In The SDLC: The software life cycle is typically divided up into stages going from
abstract descriptions of the problem to designs then to code and testing and finally to deployment.
The earliest stages of this process are analysis (requirements) and design.The distinction between
analysis and design is often described as “what Vs how”.
In analysis developers work with users and domain experts to define what the system is supposed
to do. Implementation details are supposed to be mostly or totally ignored at this phase.
The goal of the analysis phase is to create a model of the system regardless of constraints such as
appropriate technology. This is typically done via use cases and abstract definition of the most
important objects using conceptual model.
1
The design phase refines the analysis model and applies the needed technology and other
implementation constrains.
It focuses on describing the objects, their attributes, behavior, and interactions. The design model
should have all the details required so that programmers can implement the design in code.
Object-Oriented Analysis:
1. Elicit requirements: Define what does the software need to do, and what’s the problem
the software trying to solve.
2. Specify requirements: Describe the requirements, usually, using use cases (and scenarios)
or user stories.
3. Conceptual model: Identify the important objects, refine them, and define their
relationships and behavior and draw them in a simple diagram.
Object-Oriented Design:
The analysis phase identifies the objects, their relationship, and behavior using the conceptual
model (an abstract definition for the objects).
While in design phase, we describe these objects (by creating class diagram from conceptual
diagram — usually mapping conceptual model to class diagram), their attributes, behavior, and
interactions.
In addition to applying the software design principles and patterns which will be covered in later
tutorials.
The input for object-oriented design is provided by the output of object-oriented analysis. But,
analysis and design may occur in parallel, and the results of one activity can be used by the other.
A class diagram gives a visual representation of the classes you need. And here is where you
get to be really specific about object-oriented principles like inheritance and polymorphism.
Describing the interactions between those objects lets you better understand the responsibilities
of the different objects, the behaviors they need to have.
2
Definition: A complex system is a system composed of many components which may interact
with each other. Examples of complex systems are Earth's global climate, organisms, the human
brain, infrastructure such as power grid, transportation or communication systems, social and
economic organizations.
Software Systems: Software systems are not any different from other systems with respect to
these characteristics. Thus, they are also embedded within some operational environment, and
perform operations.
Thus, they are also embedded within some operational environment, and perform operations
which are clearly defined and distinguished from the operations of other systems in this
environment.
They also have properties which emerge from the interactions of their components and/or the
interactions of themselves with other systems in their environment.
A system that embodies one or more software subsystems which contribute to or control a
significant part of its overall behavior is what we call a software intensive system.
Complexity: Complexity depends on the number of the components embedded in them as well as
the relationships and the interactions between these components which carry;
Examples of Complex Systems: The structure of personal computer, plants and animals, matter,
social institutions are some examples of complex system.
3
CPU encompasses primary memory, an ALU, and a bus to which peripheral
devices are attached.
An ALU may be divided into registers which are constructed from NAND gates,
inverters and so on. All are the hierarchical nature of a complex system.
• Computer System
• CPU, Input, Output
• ALU, CU, Registers
• Logic Gates
• we can decompose, in hierarchy, and use different level of abstraction
Plants are complex multicellular organism which are composed of cells which is
turn encompasses elements such as chloroplasts, nucleus, and so on.
For example, at the highest level of abstraction, roots are responsible for
absorbing water and minerals from the soil.
Roots interact with stems, which transport these raw materials up to the leaves.
The leaves in turn use water and minerals provided by stems to produce food through
photosynthesis.
Nuclear physicists are concerned with a structural hierarchy of matter. Atoms are made
up of electrons, protons and neutrons.
Elements and elementary particles but protons, neutrons and other particles are formed
from more basic components called quarks, which eventually formed from pro-quarks.
In social institutions, group of people join together to accomplish tasks that cannot be
done by made of divisions which in turn contain branches which in turn encompass local
offices and so on
4
• Organizations
• Branches
• Departments
Offices
The Properties of Complex and Simple Software Systems: Software may involve elements of
great complexity which is of different kind.
5
Attributes of Complex System:
The five Attributes of a complex system: There are five attribute common to all complex systems.
They are as follows:
The choice of what components in a system are primitive is relatively arbitrary and is
largely up to the discretion of the observer of the system class structure and the object
structure are not completely independent each object in object structure represents a
specific instance of some class.
Intra-component linkages are generally stronger than inter-component linkages. This fact
has the involving the high frequency dynamics of the components-involving the internal
structure of the components – from the low frequency dynamic involving interaction
among components.
4. Combine and arrange common rearranging subsystems:( common patterns)
Hierarchic systems are usually composed of only a few different kinds of subsystems in
various combinations and arrangements.
In other words, complex systems have common patterns. These patterns may
involve the reuse of small components such as the cells found in both plants or animals,
or of larger structures, such as vascular systems, also found in both plants and animals.
A complex system that works is invariably bound to have evolved from a simple system
that worked .............. A complex system designed from scratch never works and can't be
patched up to make it work. You have to start over, beginning with a working simple
system.
Booch has identified five properties that architectures of complex software systems have in
common.
Firstly, every complex system is decomposed into a hierarchy of subsystems. This
decomposition is essential in order to keep the complexity of the overall system manageable.
These subsystems, however, are not isolated from each other, but interact with each
other.
6
The discovery of common abstractions and mechanisms greatly facilitates our understanding of
complex systems.
For example, with just a few minutes of orientation, an experienced pilot can step into a
multiengine jet aircraft he or she has never flown before and safely fly the vehicle.
Having recognized the properties common to all such aircraft, such as the functioning of
the rudder, ailerons, and throttle, the pilot primarily needs to learn what properties are unique to
that particular aircraft.
If the pilot already knows how to fly a given aircraft, it is far easier to learn how to fly a
similar one.
One mechanism to simplify concerns in order to make them more manageable is to identify and
understand abstractions common to similar objects or activities. We can use a car as an example
(which are considerable complex systems).
Understanding common abstractions in this particular example would, for instance, involve the
insight that clutch, accelerator and brakes facilitate the use of a wide range of devices, namely
transport vehicles depending on transmission of power from engine to wheels).
In the car example, this could be, for instance, the distinction between physical structure of the
car (chassis, body, engine), functions the car performs (forward, back, turn) and control systems
the car has (manual, mechanical, and electrical).
In object-orientation, the class structure and the object structure relationship is the simplest form
of related hierarchy. It forms a canonical representation for object oriented analysis.
The canonical form of a complex system – the discovery of common abstractions and
mechanisms greatly facilitates are standing of complex system.
For example, if a pilot already knows how to fly a given aircraft, it is easier to know how to fly a
similar one.
7
May different hierarchies are present within the complex system. For example an aircraft may be
studied by decomposing it into its propulsion system.
Flight control system and so on the decomposition represent a structural or "part of" hierarchy.
The complex system also includes an "Is A" hierarchy.
These hierodules for class structure and object structure combining the concept of the class and
object structure together with the five attributes of complex system,
virtually all complex system take on the same (canonical) form as shown in figure. There are two
orthogonal hierarchies of system, its class structure and the object structure.
Figure 1.1
class C4 is also a class C1 and therefore has every single property that C1 has C4, however, may
have more specific properties that C1 does not have; hence the distinction between C1 and C4.
Definition: Certainly, there will always be geniuses among us, people of extraordinary skill who
can do the work of a handful of mere mortal developers, the software engineering equivalents of
Frank Lloyd Wright or Leonardo da Vinci. These are the people whom we seek to deploy as our
system architects: the ones who devise innovative idioms, mechanisms, and frameworks that
others can use as the architectural foundations of other applications or systems.
8
Principles that will provide basis for development
Abstraction
Hierarchy
Decomposition
Hierarchy: Identifying the hierarchies within a complex software system makes understanding
of the system very simple. The object structure is important because it illustrates how different
objects collaborate with one another through pattern of interaction (called mechanisms).
By classifying objects into groups of related abstractions (for example, kinds of plant
cells versus animal cells, we come to explicitly distinguish the common and distinct properties of
different objects, which helps to master their inherent complexity.
Different hierarchies support the recognition of higher and lower orders. A class high in the
‘is-a’ hierarchy is a rather abstract concept and a class that is a leaf represents a fairly concrete
concept.
The ‘is-a’ hierarchy also identifies concepts, such as attributes or operations, that are
common to a number of classes and instances.
9
Algorithmic decomposition
Object oriented decomposition: Objects are identified as Master file and check sum which
derive directly from the vocabulary of the problem.
We know the world as a set of autonomous agents that collaborate to perform some
higher level behavior. Get formatted update thus does not exist as an independent algorithm;
rather it is an operation associated with the object file of updates.
Calling this operation creates another object, update to card. In this manner, each object
in our solution embodies its own unique behavior.
Each hierarchy in layered with the more abstract classes and objects built upon more
primitive ones especially among the parts of the object structure, object in the real world. Here
decomposition is based on objects and not algorithms.
10
The algorithmic view highlighst the ordering of events and the object oriented view
emphasizes the agents that either cause action or are the subjects upon which these operations
act.
We must start decomposing a system either by algorithms or by objects then use the
resulting structure as the framework for expressing the other perspective generally object
oriented view is applied because this approach is better at helping us organize the inherent
complexity of software systems.
object oriented algorithm has a number of advantages over algorithmic decomposition.
Object oriented decomposition yields smaller systems through the reuse of common
mechanisms, thus providing an important economy of expression and are also more resident to
change and thus better able to involve over time and it also reduces risks of building complex
software systems.
Definition: Every engineering discipline involves elements of both science and art. The
programming challenge is a large scale exercise in applied abstraction and thus requires the
abilities of the formal mathematician blended with the attribute of the competent engineer. The
role of the engineer as artist is particularly challenging when the task is to design an entirely new
system.
The meaning of Design: In every engineering discipline, design encompasses the discipline
approach we use to invent a solution for some problem, thus providing a path from requirements
to implementation.
11
4. Satisfies implicit or explicit design criteria on the form of the artifact
5. Satisfies restrictions on the design process itself, such as its length or cost, or the available
for doing the design.
the purpose of design is to create a clean and relatively simple internal structure, sometimes also
called as architecture. A design is the end product of the design process.
The buildings of models have a broad acceptance among all engineering disciplines largely because
model building appeals to the principles of decomposition, abstraction and hierarchy.
Each model within a design describes a specific aspect of the system under consideration.
Models give us the opportunity to fail under controlled conditions.
The models of object oriented analysis and design reflect the importance of explicitly
capturing both the class and object hierarchies of the system under design.
These models also over the spectrum of the important design decisions that we must
consider in developing a complex system and so encourage us to craft implementations that
embody the five attributes of well formed complex systems.
12
Booch presents a model of object-oriented development that identifies several relevant
perspectives. The classes and objects that form the system are identified in a logical model. For
this logical model, again two different perspectives have to be considered.
A static perspective identifies the structure of classes and objects, their properties and the
relationships classes and objects participate in.
A dynamic model identifies the dynamic behavior of classes and objects, the different
valid states they can be in and the transitions between these states.
Besides the logical model, also a physical model needs to be identified. This is usually done
later in the system's lifecycle.
The module architecture identifies how classes are kept in separately compliable modules and
the process architecture identifies how objects are distributed at run- time over different operating
system processes and identifies the relationships between those.
The elements of the object oriented technology collectively known as the object model. The
object model encompasses the principles of abstraction, encapsulation, modularity, hierarchy,
typing, concurrency and persistency.
13
ALGOL 60 - having features of block structure, data type
COBOL - having features of data, descriptions, file handing
LISP - List processing, pointers, garbage collection
Visual Basic – Eased development of the graphical user interface (GUI) for windows
applications
Java – Successor to Oak; designed for portability
Python – Object oriented scripting language
J2EE – Java based framework for enterprise computing
NET – Microsoft’s object based framework
Visual C# - Java competitor for the Microsoft .NET framework
Visual Basic .NET – VB for Microsoft .NET framework
Topology means basic physical building blocks of the language & how those parts can be connected.
- Arrows indicate dependency of subprograms on various data.
- Error in one part of program effect across the rest of system.
14
The Topology of First- and Early Second-Generation Programming Languages
Larger project means larger team, so need to develop different parts of same program
independently, i.e. complied module.
- Support modular structure.
15
Topology of object and object oriented programming language :
16
Foundations of the object model:
In structured design method, build complex system using algorithm as their fundamental
building block. An object oriented programming language, class and object as basic building
block.
We would add to this list three more contributions to the foundation of the object model:
Advances in database models
Research in artificial intelligence
Advances in philosophy and cognitive science
During software requirement phase, requirement analysis and object analysis, it is a method of
analysis that examines requirements from the perspective of classes and objects as related to
problem domain. Object oriented analysis emphasizes the building of real-world model using the
object oriented view of the world.
During user requirement phase, OOD involves understanding of the application domain and
build an object model. Identify objects; it is methods of design showing process of object
oriented decomposition.
Object oriented design is a method of design encompassing the process of object oriented
decomposition and a notation for depicting both logical and physical as well as static and
dynamic models of the system under design.
17
It supports objects that are data abstractions with an interface of named operations and a
hidden local state.
Objects have associated type (class).
Classes may inherit attributes from supertype to subtype.
According to Jenkins and Glasgow, most programmers work in one language and use
only one programming style. They have not been exposed to alternate ways of thinking about a
problem. Programming style is a way of organizing programs on the basis of some conceptual
model of programming and an appropriate language to make programs written in the style clear.
Each requires a different mindset, a different way of thinking about the problem. Object model is
the conceptual frame work for all things of object oriented.
There are four major elements of object model. They are:
1. Abstraction
2. Encapsulation
3. Modularity
4. Hierarchy
Abstraction :
Abstraction is defined as a simplified description or specification of a system that
emphasizes some of the system details or properties while suppressing others. A good abstraction
is one that emphasizes details that are significant to the reader or user and suppresses details that
are, not so significant, immaterial.
An abstraction denotes the essential characteristics of an object that distinguishes it from
all other kinds of objects and thus provides crisply defined conceptual boundaries on the
perspective of the viewer.
An abstraction focuses on the outside view of an object, Abstraction focuses up on the
essential characteristics of some object, relative to the perspective of the viewer. From the most
to the least useful, these kinds of abstraction include following.
18
Entity abstraction: An object that represents a useful model of a problem domain or
solution domain entity.
Action abstraction: An object that provides a generalized set of operations all of which
program the same kind of function.
Virtual machine abstractions: An object that groups together operations that are used by
some superior level of control, or operations that all use some junior set of operations.
Coincidental abstraction: An object that packages a set of operations that have no relation
to each other.
Modularity:
The act of partitioning a program into individual components is called modularity. It is reusable
component which reduces complexity to some degree. Although partitioning a program is
helpful for this reason, a more powerful justification for partitioning a program is that it creates a
number of well-defined, documented boundaries within the program.
19
These boundaries, or interfaces, are invaluable in the comprehension of the program. In some
languages, such as Smalltalk, there is no concept of a module, so the class forms the only
physical unit of decomposition.
Java has packages that contain classes. In many other languages, including Object Pascal,
C++, and Ada, the module is a separate language construct and therefore warrants a separate set
of design decisions. In these languages, classes and objects form the logical structure of a
system; we place these abstractions in modules to produce the system’s physical architecture.
Modularity is the property of a system that has been decomposed into a set of cohesive and
loosely coupled modules.
- modules can be compiled separately. modules in C++ are nothing more than separately
compiled files, generally called header files.
- Interface of module are files with .h extensions & implementations are placed in files with
.c or .cpp suffix.
- modules Serve as physical containers in which classes and objects are declared like gates
in IC of computer.
- Group logically related classes and objects in the same module.
- E.g. consider an application that runs on a distributed set of processors and uses a
message passing mechanism to coordinate their activities.
- A poor design is to define each message class in its own module; so difficult for users to
find the classes they need. Sometimes modularization is worse than no modulation at all.
- Developer must balance: desire to encapsulate abstractions and need to make certain
abstractions visible to other modules.
- Principles of abstraction, encapsulation and modularity are synergistic (having common
effect)
Example of modularity:
-
Let’s look at modularity in the Hydroponics Gardening System. Suppose we decide to use a
commercially available workstation where the user can control the system’s operation. At this
workstation, an operator could create new growing plans, modify old ones, and follow the
progress of currently active ones.
Since one of our key abstractions here is that of a growing plan, we might therefore
create a module whose purpose is to collect all of the classes associated with individual growing
plans (e.g., FruitGrowingPlan, GrainGrowingPlan).
20
The implementations of these GrowingPlan classes would appear in the implementation
of this module. We might also define a module whose purpose is to collect all of the code
associated with all user interface functions.
Hierarchy:
Inheritance defines a relationship among classes. Where one classes shares structure or behaviors
defined in one (single in heritance) or more class (multiple inheritance) & thus represents a
hierarchy of abstractions in which a subclass inherits from one or more super classes.
Consider the different kinds of growing plans we might use in the Hydroponics
Gardening System. An earlier section described our abstraction of a very generalized growing
plan. Different kinds of crops, however, demand specialized growing plans.
For example, the growing plan for all fruits is generally the same but is quite different
from the plan for all vegetables, or for all floral crops.
FruitGrowingPlan GrowingPlan
Is a
In this case, FruitGrowingPlan is more specialized, and GrowingPlan is more general. The same
could be said for GrainGrowingPlan or VegetableGrowingPlan, that is, GrainGrowingPlan “is a”
kind of GrowingPlan, and VegetableGrowingPlan “is a” kind of GrowingPlan. Here,
GrowingPlan is the more general superclass, and the others are specialized subclasses.
21
As we evolve our inheritance hierarchy, the structure and behavior that are common for different
classes will tend to migrate to common super classes. This is why we often speak of inheritance
as being a generalization/specialization hierarchy.
The Rose Class, Which Inherits from Multiple Superclasses (Multiple Inheritance)
Repeated inheritance occurs when two or more peer superclasses share a common superclass.
Hierarchy: Aggregation
22
For example, consider the abstraction of a garden. We can contend that a garden consists of a
collection of plants together with a growing plan.
In other words, plants are “part of” the garden, and the growing plan is “part of” the garden.
This “part of” relationship is known as aggregation.
Aggregation raises the issue of ownership. Our abstraction of a garden permits different plants
to be raised in a garden over time, but replacing a plant does not change the identity of the
garden as a whole, nor does removing a garden necessarily destroy all of its plants (they are
likely just transplanted).
In other words, the lifetime of a garden and its plants are independent. In contrast, we have
decided that a GrowingPlan object is intrinsically associated with a Garden object and does not
exist independently.
Type and class are used interchangeably class implements a type. Typing is the enforcement of
the class of an object. Such that object of different types may not be interchanged.
Typing implements abstractions to enforce design decisions. E.g. multiplying temp by a unit of
force does not make serve but multiplying mass by force does. So this is strong typing.
Example of strong and weak typing: In strong type, type conformance is strictly enforced.
Operations can not be called upon an object unless the exact signature of that operation is
defined in the object's class or super classes.
A given programming language may be strongly typed, weakly typed, or even untyped, yet still
be called object-oriented.
A strongly typed language is one in which all expressions defined in super class are guaranteed
to be type consistent. When we divide distance by time, we expect some value denoting speed,
not weight. Similarly, dividing a unit of force by temperature doesn’t make sense, but dividing
force by mass does. These are both examples of strong typing, wherein the rules of our domain
prescribe and enforce certain legal combinations of abstractions.
23
• Without type checking, program can crash at run time
Most compilers can generate more efficient object code if types are declared
Static typing (static binding/early binding) refers to the time when names are bound to types i.e.
types of all variables are fixed at the time of compilation.
Dynamic binding (late binding) means that types of all variables and expressions are not known
until run time. Dynamic building (object pascal, C++) small talk (untyped).
Polymorphism: is a condition that exists when the features of dynamic typing and inheritance
interact. Polymorphism represents a concept in type theory in which a single name (such as a
variable declaration) may denote objects of many different classes that are related by some
common superclass. The opposite of polymorphism is monomorphism, which is found in all
languages that are both strongly and statically typed.
Concurrency:
Such objects are called active. In a system based on an object oriented design, we can
conceptualize the word as consisting of a set of cooperative objects, some of which are active
(serve as centers of independent activity) . Thus concurrency is the property that distinguishes
an active object from one that is not active.
For example: If two active objects try to send messages to a third object, we must be
certain to use some means of mutual exclusion, so that the state of object being acted upon is
not computed when both active objects try to update their state simultaneously. In the preserve
of concurrency, it is not enough simply to define the methods are preserved in the presence of
multiple thread of control.
Examples of Concurrency:
24
this behavior. That fact is a secret of the implementation, but it is clear that some form of
concurrency is required.
• We may use a class library that implements some form of light weight process AT & T
task library for C++ provides the classes’ sched, Timer, Task and others. Concurrency
appears through the use of these standard classes.
• Use of interrupts to give the illusion of concurrency use of hardware timer in active
Temperature sensor periodically interrupts the application during which time all the
sensor read the current temperature, then invoke their callback functions as necessary.
Persistence:
Persistence is the property of an object through which its existence transcends time and or space
i.e. objects continues to exist after its creator ceases to exist and/or the object's location moves
from the address space in which it was created. An object in software takes up some amount of
space and exists for a particular amount of time. Object persistence encompasses the followings.
Introducing the concept of persistence to the object model gives rise to object oriented
databases. In practice, such databases build upon some database models (Hierarchical, network
relational). Database queries and operations are completed through the programmer abstraction
of an object oriented interface.
Persistence deals with more than just the lifetime of data. In object oriented databases,
not only does the state of an object persist, but its class must also transcend only individual
program, so that every program interprets this saved state in the same way.
25
In most systems, an object once created, consumes the same physical memory until it
classes to exist. However, for systems that execute upon a distributed set of processors, we must
sometimes be concerned with persistence across space. In such systems, it is useful to think of
objects that can move from space to space.
Use of object model helps us to exploit the expressive power of object based and object
oriented programming languages. Without the application of elements of object model,
more powerful feature of languages such as C++, object pascal, ada are either ignored or
greatly misused.
Use of object model encourages the reuse of software and entire designs, which results
in the creation of reusable application framework.
Use of object model produces systems that are built upon stable intermediate forms,
which are more resilent to change.
Object model appears to the working of human cognition, many people who have no
idea how a computer works find the idea of object oriented systems quite natural.
Application of Object Model:
OOA & Design may be in only method which can be employed to attack the complexity
inherent in large systems. Some of the applications of the object model are as follows:
26