SADP_T1_M1_P2
SADP_T1_M1_P2
SADP_T1_M1_P2
io
INSTAGRAM: www.instagram.com/hemanthraj_hemu/
INSTAGRAM: www.instagram.com/futurevisionbie/
xiii
https://hemanthrajhemu.github.io
Chapter 1
Introduction
The object-oriented paradigm is currently the most popular way of analysing, design-
ing, and developing application systems, especially large ones. To obtain an under-
standing of this paradigm, we could begin by asking: What exactly does the phrase
‘object-oriented’ mean? Looking at it quite literally, labelling something as ‘object-
oriented’ implies that objects play a central role, and we elaborate this further as a
perspective that views the elements of a given situation by decomposing them into
objects and object relationships. In a broad sense, this idea could apply to any setting
and examples of its application can in fact be found in business, chemistry, engineer-
ing and, even philosophy. Our business is with creating software and therefore this
book concentrates on the object-oriented analysis, design, and implementation of
software systems. Our situations are therefore problems that are amenable to software
solutions, and the software systems that are created in response to these problems.
Designing is a complex activity in any context simply because there are competing
interests and we have to make critical choices at each step with incomplete informa-
tion. As a result, decisions are often made using some combination of rules of thumb
derived from past experience. Software design is no exception to this, and in the
process of designing a system, there are several points where such decisions have to
be made. Making informed choices in any field of activity requires an understanding
of the underlying philosophy and the forces that have shaped it. It is therefore appro-
priate to start our study of object-oriented software analysis and design by outlining
its philosophy and the developments in this field up to the present time. Throughout
the case studies used in this text, the reader will find examples of how this guiding
philosophy is helping us make choices at all stages.
This chapter, therefore, intends to give the reader a broad introduction to the
complex topic of object-oriented software development. We start with an overview of
the circumstances that motivated its development and why it came to be the desired
approach for software development. In the course of this discussion, we present
https://hemanthrajhemu.github.io
4 1 Introduction
the central concepts that characterise the methodology, how this development has
influenced our view of software, and some of its pros and cons. We conclude by
presenting a brief history of the evolution of the object-oriented approach.
The traditional view of a computer program is that of a process that has been encoded
in a form that can be executed on a computer. This view originated from the fact that
the first computers were developed mainly to automate a well-defined process (i.e.,
an algorithm) for numerical computation, and dates back to the first stored-program
computers. Accordingly, the software creation process was seen as a translation from
a description in some ‘natural’ language to a sequence of operations that could be
executed on a computer. As many would argue, this paradigm is still the best way
to introduce the notion of programming to a beginner, but as systems became more
complex, its effectiveness in developing solutions became suspect. This change of
perspective on part of the software developers happened over a period of time and was
fuelled by several factors including the high cost of development and the constant
efforts to find uses for software in new domains. One could safely argue that the
software applications developed in later years had two differentiating characteristics:
• Behaviour that was hard to characterise as a process
• Requirements of reliability, performance, and cost that the original developers did
not face
The ‘process-centred’ approach to software development used what is called top-
down functional decomposition. The first step in such a design was to recognise
what the process had to deliver (in terms of input and output of the program), which
was followed by decomposition of the process into functional modules. Structures
to store data were defined and the computation was carried out by invoking the
modules, which performed some computation on the stored data elements. The life
of a process-centred design was short because changes to the process specification
(something relatively uncommon with numerical algorithms when compared with
business applications) required a change in the entire program. This in turn resulted
in an inability to reuse existing code without considerable overhead. As a result,
software designers began to scrutinise their own approaches and also study design
processes and principles that were being employed by engineers in other disciplines.
Cross-pollination of ideas from other engineering disciplines started soon after, and
the disciplines of ‘software design’ and ‘software engineering’ came into existence.
In this connection, it is interesting to note the process used for designing simple
electromechanical systems. For several decades now, it has been fairly easy for
people with limited knowledge of engineering principles to design and put together
simple systems in their backyards and garages. So much so, it has become a hobby
that even a 10 years old could pursue. The reasons for this success are easy to see:
easily understandable designs, similar (standard) solutions for a host of problems, an
https://hemanthrajhemu.github.io
1.1 What Is Object-Oriented Development? 5
During the development of this paradigm, as one would expect, several ideas and
approaches were tried and discarded. Over the years the field has stabilised so that
we can safely present the key ideas whose soundness has stood the test of time.
https://hemanthrajhemu.github.io
6 1 Introduction
requirements of the application. The execution of each process relies heavily on the
objects to store the data and provide the necessary operations; with some additional
work, the entire system is ‘assembled’ from the objects.
Standard Solutions
The existence of an object structure facilitates the documenting of standard solu-
tions, called design patterns. Standard solutions are found at all stages of software
development, but design patterns are perhaps the most common form of reuse of
solutions.
https://hemanthrajhemu.github.io
1.3 Other Related Concepts 7
Each module provides certain functionality; cohesion of a module tells us how well
the entities within a module work together to provide this functionality. Cohesion is a
measure of how focused the responsibilities of a module are. If the responsibilities of
a module are unrelated or varied and use different sets of data, cohesion is reduced.
Highly cohesive modules tend to be more reliable, reusable, and understandable
than less cohesive ones. To increase cohesion, we would like that all the constituents
contribute to some well-defined responsibility of the module. This may be quite a
challenging task. In contrast, the worst approach would be to arbitrarily assign entities
to modules, resulting in a module whose constituents have no obvious relationship.
https://hemanthrajhemu.github.io
8 1 Introduction
Coupling refers to how dependent modules are on each other. The very fact that
we split a program into multiple modules introduces some coupling into the system.
Coupling could result because of several factors: a module may refer to variables
defined in another module or a module may call methods of another module and use
the return values. The amount of coupling between modules can vary. In general, if
modules do not depend on each others implementation, i.e., modules depend only on
the published interfaces of other modules and not on their internals, we say that the
coupling is low. In such cases, changes in one module will not necessitate changes
in other modules as long as the interfaces themselves do not change. Low coupling
allows us to modify a module without worrying about the ramifications of the changes
on the rest of the system. By contrast, high coupling means that changes in one module
would necessitate changes in other modules, which may have a domino effect and
also make it harder to understand the code.
Testability of a concept, in general, refers to both falsifiability, i.e., the ease with
which we can find counterexamples, and the practical feasibility of reproducing such
counterexamples. In the context of software systems, it can simply be stated as the
ease with which we can find bugs in a software and the extent to which the structure
of the system facilitates the detection of bugs. Several concepts in software testing
(e.g., the idea of unit testing) owe their prominence to concepts that came out of the
development of the object-oriented paradigm.
https://hemanthrajhemu.github.io
1.4 Benefits and Drawbacks of the Paradigm 9
1. Objects often reflect entities in application systems. This makes it easier for a
designer to come up with classes in the design. In a process-oriented design, it is
much harder to find such a connection that can simplify the initial design.
2. Object-orientation helps increase productivity through reuse of existing software.
Inheritance makes it relatively easy to extend and modify functionality provided
by a class. Language designers often supply extensive libraries that users can
extend.
3. It is easier to accommodate changes. One of the difficulties with application
development is changing requirements. With some care taken during design, it is
possible to isolate the varying parts of a system into classes.
4. The ability to isolate changes, encapsulate data, and employ modularity reduces
the risks involved in system development.
The above advantages do not come without a price tag. Perhaps the number one casu-
alty of the paradigm is efficiency. The object-oriented development process intro-
duces many layers of software, and this certainly increases overheads. In addition,
object creation and destruction is expensive. Modern applications tend to feature a
large number of objects that interact with each other in complex ways and at the same
time support a visual user interface. This is true whether it is a banking application
with numerous account objects or a video game that has often a large number of
objects. Objects tend to have complex associations, which can result in non-locality,
leading to poor memory access times.
Programmers and designers schooled in other paradigms, usually in the imperative
paradigm, find it difficult to learn and use object-oriented principles. In coming up
with classes, inexperienced designers may rely too heavily on the entities in the
application system, ending up with systems that are ill-suited for reuse. Programmers
also need acclimatisation; some people estimate that it takes as much as a year for
a programmer to start feeling comfortable with these concepts. Some researchers
are of the opinion that the programming environments also have not kept up with
research in language capabilities. They feel that many of the editors and testing and
debugging facilities are still fundamentally geared to the imperative paradigm and
do not directly support many of the advances such as design patterns.
1.5 History
https://hemanthrajhemu.github.io
10 1 Introduction
Toward the end of the 1970s, Bjarne Stroustrup, who was doing doctoral work in
England, needed a language for doing simulation of distributed systems. He devel-
oped a language based on the class concept in Simula, but this language was not
particularly efficient. However, he pursued his attempt and developed an object-
oriented language at Bell Laboratories as a derivative of C, which would blossom
into one of the most successful programming languages, C++. The language was
standardised in 1997 by the American National Standards Institute (ANSI).
The 1980s saw the development of several other languages such as ObjectLisp,
CommonLisp, Common Lisp Object System (CLOS), and Eiffel. The rising pop-
ularity of the object-oriented model also propelled changes to the language Ada,
originally sponsored by the U.S. Department of Defense in 1983. This resulted in
Ada 9x, an extension to Ada 83, with object-oriented concepts including inheritance,
polymorphism, and dynamic binding.
The 1990s saw two major events. One was the development of the Java program-
ming language in 1996. Java appeared to be a derivative of C++, but many of the
controversial and troublesome concepts in C++ were deleted in it. Although it was a
relatively simple language when it was originally proposed, Java has undergone sub-
stantial additions in later versions making it a moderately difficult language. Java also
comes with an impressive collection of libraries (called packages) to support applica-
tion development. A second watershed event was the publication of the book Design
Patterns by Gamma et al. in 1994. The book considered specific design questions
(23 of them) and provided general approaches to solving them using object-oriented
constructs. The book (as also the approach it advocated) was a huge success as both
practitioners and academicians soon recognised its significance.
The last few years saw the acceptance of some dynamic object-oriented languages
that were developed in the 1990s. Dynamic languages allow users more flexibility,
for example the ability to dynamically add a method to an object at execution time.
One such language is Python, which can be used for solving a variety of applications
including web programming, databases, scientific and numeric computations and
networking. Another dynamic language, Ruby, is even more object-oriented in that
everything in the language, including numbers and primitive types, is an object.
https://hemanthrajhemu.github.io
1.6 Discussion and Further Reading 11
a standard text on the subject such as Sebesta [1]. The reader might also find it helpful
to get the perspectives of the designers of object-oriented languages (such as the one
given on C++ by Stroustrup [2]).
1.7 Exercises
1. Identify the players who would have a stake in software development process.
What are the concerns of each? How would they benefit from the object-oriented
model?
2. Think of some common businesses and the activities software developers are
involved in. What are the sets of processes they would like to automate? Are
there any that need software just for one process?
3. How does the object-oriented model support the notion of ADTs and encapsula-
tion?
4. Consider an application that you are familiar with, such as a university system.
Divide the entities of this application into groups, thus identifying the classes.
5. In Question 4, suppose we put all the code (corresponding to all of the classes)
into one single class. What happens to cohesion and coupling?
6. What are the benefits of learning design patterns?
References
https://hemanthrajhemu.github.io