Ooad Unit 1
Ooad Unit 1
Industrial-strength software
Industrial-strength software applications exhibits a very rich set of behaviors, for example, in
reactive systems that drive or are driven by events in the physical world, and for which time and
space are scarce resources; applications that maintain the integrity of hundreds of thousands of
records of information while allowing concurrent updates and queries; and systems for the
command and control of real-world entities, such as the routing of air or railway traffic. Software
systems such as these tend to have a long life span, and over time, many users come to depend
on their proper functioning. Complexity of Industrial-Strength Software systems exceeds the
human intellectual capacity
Hierarchic Structure
All systems are composed of interrelated sub-systems
Sub-systems are composed of sub-sub-systems, and so on
3
Lowest level sub-systems are composed of elementary components
All systems are parts of larger systems
The value added by a system must come from the relationships between the parts, not
from the parts per se
We can understand only those systems that have a hierarchic structure
Relative Primitives
Subjective Choice — strongly dependent on the experience and expertise of the designer
What is primitive for one observer may be at a much higher level of abstraction for
another.
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
Separation of Concerns
Hierarchic systems are:
decomposable — can be divided into identifiable parts
nearly decomposable — the parts are not completely independent
Difference between intra- and intercomponent interactions provides a clear Separation of
Concerns among the various parts of a system — helps the analysis and design in
isolation
Common Patterns
Complex systems have Common Patterns
Complex systems are composed of only a few different kinds of subsystems in various
combinations and arrangements (cells found in both plants and animals etc.)
Common Patterns are a major source of reuse in OOAD. Examples include Design
Patterns, STL in C++, Data Structures in Python etc.
5
Figure 1–1 The Canonical Form of a Complex System
Decomposition
Abstraction
Hierarchy
6
The Role of Decomposition
Decomposition techniques are divided into two types they are
Algorithmic Decomposition
Object-Oriented Decomposition
Algorithmic Decomposition: Decomposition is important techniques for copying with
complexity based on the idea of divide and conquer. In dividing a problem into a sub problem
the problem becomes less complex and easier to overlook and to deal with. Repeatedly dividing
a problem will eventually lead to sub problems that are small enough so that they can be
conquered. After all the sub problems have been conquered and solutions to them have been
found, the solutions need to be composed in order to obtain the solution of the whole problem.
The history of computing has seen two forms of decomposition, process-oriented (Algorithmic)
and object-oriented decomposition.
Example:
Object-Oriented Decomposition: Objects are identified as Master file and check sum which
derive directly from the vocabulary of the problem. We view the world as a set of autonomous
agents that collaborate to perform some higher level behavior. Calling one operation creates
another object. In this manner, each object 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
7
objects and not algorithms.
Example:
Identify objects like Master File and Checksum directly from the problem
The Role of Abstraction: Abstraction is an exceptionally powerful technique for dealing with
complexity. Unable to master the entirely of a complex object, we choose to ignore its inessential
details, dealing instead with the generalized, idealized model of the object. For example, when
studying about how photosynthesis works in a plant, we can focus upon the chemical reactions in
certain cells in a leaf and ignore all other parts such as roots and stems. Objects are abstractions
of entities in the real world.
In general abstraction assists people's understanding by grouping, generalizing and chunking
information.
Object-orientation attempts to deploy abstraction. The common properties of similar objects are
defined in an abstract way in terms of a class. Properties that different classes have in common
are identified in more abstract classes and then an ‗is-a‘ relationship defines the inheritance
between these classes.
The Role of Hierarchy: Increase the semantic content of individual chunks of information by
explicitly recognizing the class and object hierarchies. Object structure illustrates how different
objects collaborate with one another through patterns of interaction that we call mechanisms
Class structure highlights common structure and behavior within a system.
8
Designing Complex Systems:
Engineering as a Science and an Art: 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: The purpose of design is to construct a system that:
The Importance of Model Building: 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. We evaluate each model under both expected and unusual situations and then after
them when they fail to behave as we expect or desire. More than one kind of model is used on
order to express all the subtleties of a complex system.
The Elements of Software design Methods: Design of complex software system involves an
incremental and iterative process. Each method includes the following:
The models of Object Oriented Development: 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.
9
typing, concurrency and persistency. The object model brought together these elements in a
synergistic way.
10
Second-generation Languages (1959-1961)
Major Features
Blocks and Subprograms
Notions of Programming:
Data Type & Description
Statements e Parameter Passing Mechanisms
Files
Pointers
List
Data Structures
Languages
FORTRAN II (Subroutines, separate compilation)
ALGOL 60 (Block structure, data types)
COBOL (Data description, file handling)
Lisp (List processing, pointers, garbage collection)
11
Abstraction
Notions of Programming:
Control Constructs
Class
One-language-fits-it-all
Languages
PL/1 (FORTRAN + ALGOL + COBOL)
ALGOL 68 (Rigorous successor to ALGOL 60)
Pascal (Simple successor to ALGOL 60)
Simula (Classes, data abstraction)
12
FORTRAN 77 (ANSI standardization)
SQL (Structured Query Language)
Applications in Object Based (OB) and Object Oriented Programming (OOP) languages
exhibit:
Fundamental logical building blocks are no longer algorithms, but instead are
classes and objects
Little or no global data
Classes, objects, and modules provide an essential yet insufficient means of
abstraction
13
Notions of Programming:
Dynamic Typing
Portability
Threads
Frameworks:
J2SE, J2EE, J2ME (Java-based frameworks for standard,
enterprise & mobile computing)
.NET (Microsoft's object-based framework)
Languages
Visual Basic (Development GUI for Windows applications)
Java (Successor to Oak; designed for portability)
Python (00 scripting, portable, dynamically typed)
Visual C# (Java competitor for .NET Framework)
VB.NET (Visual Basic for NET Framework)
14
Foundation of Object Model
Structured design methods evolved to guide developers who use procedural language and
algorithms as their fundamental building blocks to build complex system.
Similarly, object-oriented design methods have evolved to help developers who exploit the
expressive power of object-based and object-oriented programming languages, using the class
and object as basic building blocks.
With Algorithmic Decomposition alone, only limited amount of complexity can be handled —
hence we turn to Object-Oriented Decomposition. The following events have contributed to the
evolution:
Advances in computer architecture
Advances in programming languages
Advances in programming methodology
Advances in database models
Research in artificial intelligence
Advances in philosophy and cognitive science
15
Object-oriented Decomposition
Object-Oriented Programming
What is object-oriented programming (OOP)? We define it as follows:
Object-oriented programming is a method of implementation in which programs are organized as
cooperative collections of objects, each of which represents an instance of some class, and whose
classes are all members of a hierarchy of classes united via inheritance relationships.
There are three important parts to this definition:
(1) Object-oriented programming uses objects, not algorithms, as its fundamental logical
building blocks
(2) Each object is an instance of some class; and
(3) Classes may be related to one another via inheritance relationships
16
An automated gardener should efficiently carry out growing plans for the healthy
production of multiple crops
Key Abstractions:
Sensors
Heaters
Growing Plans
17
Objectives of Modularity
• Modular Decomposition
o Systematic mechanism to divide problem into individual components
• Modular Composability
o Enable reuse of existing components
• Modular Understandability
o Understand module as a unit
• Modular Protection
o Errors are localized and do not spread to other modules
Modularization: Example 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, a follow the progress of currently active ones. The Key Abstractions are Growing plan,
User Interface.
Growing plan
• Create a module whose purpose is to collect all of the classes associated with individual
growing plans (for example, FruitGrowingPlan, GrainGrowingPlan)
• The implementations of these GrowingPlan classes would appear in the implementation
of this module a
User Interface
• Another module whose purpose is to collect all of the code associated with all user
interface functions
Hierarchy
Hierarchy is a ranking or ordering of abstractions. Two most important hierarchies in a complex
system are
• Class structure or is-a hierarchy (Abstraction or IS—A)
• Object structure or part-of hierarchy (Decomposition or HAS—A)
The common structure & behavior are migrated to the superclass. Superclass represents a
generalized abstraction and subclasses represent specializations. A subclass can add, modify &
hide methods from the superclass.
18
For example, a bear ―is a‖ kind of mammal, a house ―is a‖ kind of tangible asset, and a quick sort
―is a‖ particular kind of sorting algorithm.
Typing:
The concept of a type derives primarily from the theories of abstract data types. A type is a
precise characterization of structural or behavioral properties which a collection of entities all
share. For our purposes, we will use the terms type and class interchangeably. Although the
concepts of a type and a class are similar, we include typing as a separate element of the object.
A Programming Language may be
• Statically typed
• Dynamically typed
• Strongly typed
• Weakly typed
• Untyped
Polymorphism
Single method exhibiting different behaviours in the same class or different classes is known as
polymorphism. Polymorphism is the most powerful feature of object-oriented programming
languages next to the support for abstraction.
Concurrency
Concurrency is the property that distinguishes an active object from one that is not active. It
allows multiple tasks to execute, interact and collaborate at the same time to achieve the global
functionality. Concurrency is critical for Client-Server Model of computation. Concurrency is of
two types
• Heavyweight and
• Lightweight Concurrency
Heavyweight Concurrency
A heavyweight process is typically independently managed by the target operating system and so
encompasses its own address space. Communication among heavyweight processes is expensive
and involves inter-process communication. It is commonly called a Process.
Lightweight Concurrency
A lightweight process lives within a single OS process along with other lightweight processes
and shares the same address space. Communication among lightweight processes is less
19
expensive and often involves shared data. It is commonly called a Thread.
Persistence
is the property of an object through which its existence transcends time.
Time object continues to exist after its creator ceases to exist.
Space object’s location moves from the address space in which it was created.
Benefits of the Object Model: Object model introduces several new elements which are
advantageous over traditional method of structured programming. The significant benefits are:
• 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 resilient 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.
20