An Introduction To Object Technology: The Traditional Approach
An Introduction To Object Technology: The Traditional Approach
0
)
2
6 An Introduction
-
4
to Object
Technology
1.1 THE TRADITIONAL APPROACH
dynamic.
cally from that point onwards that in the last few years, almost all
concerns regarding the hardware have been nullified, and the chief
concern of all the concerned parties in a software project is the
software itself.
All modern organizations and corporations have become informa-
tion-centric. They have quite a few areas where information con-
stantly keeps coming in, or going out. For instance, in a typical
organization, there are a number of departments, such as sales and
marketing, research and development, customer service, and so on,
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
2 Object Oriented Analysis and Design
each of which receives some information, or has to give it out. This informa-
tion can be qualitative (e.g. our product has made good inroads in the Japa-
nese market) or quantitative (e.g. we have sold 1000 units of our product in
England). Regardless, the organization must keep track of all this information,
whether it is current or of the past, and it must be able to access it as and when
required with a very short notice. The result is that information systems play
perhaps the most critical role in the day-to-day running of any modern
business.
The biggest problem faced by the organizations is trying to keep up with
this voluminous data, which seems to keep growing all the time. As we have
mentioned, the hardware is no more an issue. New hardware can be bought, or
It is common the existing hardware can be upgraded with minimum fuss. However, the key
to talk about
Giga-bytes, now is software. Writing and maintaining complex software has proved to be
something quite a challenge. There are many aspects of this, as follows.
unthinkable
even a few
1. Race between Hardware and Software The biggest problem here is that
years ago. hardware is upgraded quite frequently to fast processors, more memory and
reliable server infrastructures. However, the software has to be constantly on
its toes to keep up, and make use of this modern, better hardware. By the time
the software seems to have matched the hardware, the hardware takes another
leap: it becomes even better! How do we tackle this situation without impact-
ing any of the areas in a software project? How do we ensure that this race
between hardware and software is not won by the hardware all the time? This
race is shown in Fig. 1.1.
Race between
Hardware
and Software
Software that it is very rare to complete a software product in quick time that works as
projects are
becoming
expected, and that does not have any defects, either. The schedules and bud-
more and gets are almost always crossed, and worse yet, the resulting software is many
more complex times riddled with defects. To make matters worse, generally the software is
all the time. organized (written) in such a manner that it is very difficult to make alterations
to the software in order to deal with defects. Changes made to handle one
defect cause the effect of impacting other portions of the software. Thus,
removing one defect leads to the birth of one or more new defects (testing and
removing such new defects is a process called as regression testing, in techni-
cal terms). To summarize, the typical challenges faced by major software
projects are illustrated in Fig. 1.2.
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
An Introduction to Object Technology 3
Budget
Defects
FIG. 1.2
Create/Update
Create Customer Create Customer
Customer
Update Customer Update Customer
Create Salesperson
Delete Customer Delete Customer ll
Print Invoice
Print Invoice Print Invoice
FIG. 1.3 Weekly Report Monthly Report
Flexible Report
Web Enabling
Constantly
Changing
User Initial Requirements Requirements
Requirements Requirements Changed Changed
Copyright © 2004. Tata McGraw-Hill. All rights reserved.
Many experts call this situation as a software crisis. How do we deal with
such issues, and deliver quality software on time within the budget, at least on
most occasions, if not every time? In order to understand this, we must first
examine the traditional approach for constructing software.
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
4 Object Oriented Analysis and Design
A computer program is a series of steps that carry out the desired function-
ality. These steps are written in the form of instructions in a programming
language, which a computer can understand and execute. Usually, one person
writes one program. Such a program is called as a procedure. This works fine
as long as the size of the procedure is manageable (small). The same person is
responsible for handling changes to the procedures, and taking design deci-
sions, so as to freely move portions of the procedure’s code from one area to
the other, and so on. This is shown in Fig. 1.4.
When a Program is
FIG. 1.4 Small, It is Usually
Program Procedure
Written as a Single
Program and Procedure
Procedure
However, when the size of the overall computer application starts increas-
ing, it is no longer viable for a single programmer to write the entire applica-
tion. Many persons get together to create the program now. If we continue
Examples of
procedural
using the same approach of creating one single procedure for the entire pro-
programming gram, it usually leads to trouble. This is because, different persons write dif-
languages are ferent portions of code within the same procedure. Therefore, there is a lot of
COBOL and inter-dependency in terms of program code among the various developers of a
Pascal.
team. When one developer changes her code even in the slightest manner, it
can have a rippling effect on the rest of the code. Usually, most of the time is
spent in communicating changes, handling their effects on the other portions
of the code, and ensuring that no new errors are introduced by someone else’s
change. As the software project gathers pace, it not only becomes cumber-
some, but also so disconcerting that the project team starts spending most of
their time in issue resolution, rather than actual coding!
Ä Modular Programming
In order to deal with the issues just discussed, it will become apparent that the
one program = one procedure approach is not going to work. The simple
Copyright © 2004. Tata McGraw-Hill. All rights reserved.
solution to this problem seems to be, split one program into smaller, manage-
Structured
and modular able modules/procedures. These smaller modules should be fairly independent
programming of each other. Different persons should be able to code them independently,
are different and then finally integrate them together to form a single application program.
concepts,
although
Such a strategy is called as modular programming.
people often In the 1960s, the idea of modular programming started picking up. This
confuse them. thought process led to the concept of a subroutine. A subroutine is carved out
of the main program by physically taking out some instructions from the main
program, and placing them inside a subroutine. The main program no longer
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
An Introduction to Object Technology 5
contains these instructions. Instead, they are in the subroutine. Whenever the
main program wants to execute these instructions, it simply calls the subrou-
tine by its name. For instance, in a payroll application, a subroutine Calculate-
Some
languages salary can be carved out of the main program. The main program can call it as
use functions and when required. This is shown in Fig. 1.5. Here, the main program calls the
in the place of subroutine twice.
subroutines.
Calculate-Salary Calculate-Salary
Subroutine
Use of
Subroutines
The use of subroutines helps. This approach means that different persons
can write different subroutines, and then can assemble them all to form a single
working program. Therefore, instead of writing one program as a single proce-
dure, many subroutines can constitute a program as shown in Fig. 1.6.
Subroutine A
Although this approach sounds a lot better, and has indeed solved many of
the problems that we had noticed earlier, it has its own issues and concerns, as
Copyright © 2004. Tata McGraw-Hill. All rights reserved.
we shall see. For the moment, however, let us see how we can further enhance
Structure
charts are this approach. In order to further improve the modular programming model, we
prepared to can think about multi-level modules. That is, we need not restrict ourselves to
show the a single level of subroutines—we can expand this to multiple levels, as shown
hierarchy of
modules.
with the help of a simple example in Fig. 1.7.
As we can see, the approach here is top-down, wherein the bigger problem
statement is first divided into first level modules. We then examine to see if
any of the first level modules can be further divided into second level modules,
and so on. We stop when we reach the level of the individual subroutines.
Different programmers can write these subroutines, which are then assembled
to form a single main program.
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
6 Object Oriented Analysis and Design
Main
FIG.1.7
The modular approach works fine as long as the number and levels of
modules is not very high. However, as these numbers increase, as well as the
number of times that they need to be changed increases, this approach also
Figure 1.7 is a
structure
suffers from the drawback of maintenance overheads. The problem is that it is
chart. very difficult, if not impossible, to initially comprehend the complete scope of
an application, and therefore, the number and levels of modules. Consequently,
it often turns out that the initial division of the main program into smaller
modules is not done the right way, and amending that causes significant
overheads later on. The bigger the application, more is the number of times we
must perform the design rework, which means changes to the whole applica-
tion.
Let us now understand why this approach suffers from these drawbacks.
Ä Data Management
All along, we have been talking about only the operations, or procedures in a
program. But a program always has two aspects: operations and data, as shown
in Fig. 1.8.
Copyright © 2004. Tata McGraw-Hill. All rights reserved.
Operations
Program
= +
FIG. 1.8
A Program
Consists of Data
Operations
and Data
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
An Introduction to Object Technology 7
Interestingly, the idea of keeping the instructions (code) and the data sepa-
rate seems to have originated from hardware. In hardware, we always used to
have separate physical areas in the memory for storing instructions and data—
For example,
in most
they were never mixed. In fact, even today, that is the case in most computer
Assembly architectures, and the compilers also expect things to be that way. Software
language simply seems to have borrowed this concept from hardware!
programs, the
We have rarely spoken about data so far. That, in fact, is one of the major
instructions
are in an area causes why the traditional approaches suffer from a number of drawbacks.
of memory Imagine that there is a computer-based Sales tracking application, which tracks
called as code customers, salespeople and the sales data. At a very broad level, the applica-
segment, and
all the data tion consists of three major operations: Customer details maintenance, Sales
items are in a people details maintenance and Sales details maintenance. All the three opera-
separate area tions need some scratch pad areas to store their temporary data, such as
called as data
segment.
intermediate totals or summary reports before printing them, etc. The tradi-
tional approach would have been to allocate a common pool of data area,
called as global variables, to these three operations, and allow them to freely
use this pool of data the way they wanted. This is shown in Fig. 1.9.
FIG. 1.9
As shown in Fig. 1.10, the common pool of data is available to all the
operations, or programs, in the traditional approach of computer applications.
This approach works fine if the number of programs as well as the number of
Copyright © 2004. Tata McGraw-Hill. All rights reserved.
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
8 Object Oriented Analysis and Design
Program A
Before Program A executes
… X = 10
…
Add 10 to X
…
After Program A executes
Execute B X = 20
FIG. 1.10
Program B
Changes to a
…
Data Item by … Program B gets X = 20
One Program Add X to Y X = 20
can have …
Impacts on …
all Others
elements (i.e. global variables) would be identified after a lot of scrutiny, and
an attempt used to be made to keep the number of such commonly shared data
elements to a minimum, so as to alleviate the problems caused by shared data,
which were described earlier. For simplicity, we have not shown the global
variables here.
We will realize from our discussion so far that two concepts have now
become crucial:
l Carving out smaller modules out of a bigger high level application (Modu-
lar programming)
l Allocating local data elements to each of the modules (Local variables)
These two concepts form the basis of object technology.
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
An Introduction to Object Technology 9
FIG. 1.11
Customer Details Sales People Details Sales Details
Individual
Modules
Having their
Own Local
Data
Elements
(Local
Variables) Local Variables Local Variables Local Variables
1.2.1 Introduction
We have discussed the various problems associated with the traditional model
of procedural programming. Now is the time to examine how object technol-
ogy differs from this model. Many people have an apprehension about object
In general, the
more jargon
technology for a strange reason. This technology comes with such a big list of
you can throw terminology, buzzwords, jargon and vocabulary that it is actually quite normal
at others, the to get frightened! Therefore, our objective would be to simplify and clearly
more ‘expert’
demystify all these terms in a very simple manner.
you are
considered. The fundamental principle in object technology is an object. At the simplest
level, everything that we see, feel, touch, or smell is an object. For instance,
the book that you are holding and reading now is an object, each page in the
book is also an object, and you and me are also objects! Actually, this is a
fairly informal definition of the term object. So, let us be somewhat more
technical, and understand what an object means, soon.
The origins of object technology can be found in the 1960’s with reference
Copyright © 2004. Tata McGraw-Hill. All rights reserved.
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
10 Object Oriented Analysis and Design
Data
Object
FIG. 1.12
Object = Operations
Data +
Operations
We should state one more observation. Here, we have not talked about the
term program. Instead, we are discussing about objects. We need to note that
Object oriented
this is also a big change from our discussion so far. But it also means that we
programming need to know how objects relate to a program. In object technology, a program
literally means is simply a collection of well-designed objects. We do not think of a program
programming
as a group of data items and operations. Rather, we think of it as a group of
objects.
objects, as shown in Fig. 1.13.
Program in
Object Program
Technology
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
An Introduction to Object Technology 11
Ear
Eye
FIG. 1.14
Nose
Horse Object
and its
Attributes
that a horse can run. But how can we instruct a horse to run? If we are not able
to do so, the horse object would be quite useless to the rest of the world. This
means that we have be able to instruct the horse to perform the desired action,
such as asking it to run. Of course, object technology takes care of this aspect
by providing messages. We can pass a message to an object, requesting it to
perform a specific task. For example, we can send a message to the horse
object, asking it to run.
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
12 Object Oriented Analysis and Design
We can imagine that in the real computing world, objects need to interact
with each other in a number of ways, and for a variety of reasons. In order to
make this possible, one object can send a message to another object. This
message requests the called object to execute one of its methods. This concept
is illustrated in Fig. 1.15, where we can send a message to another object
called as dog, which results into it invoking its run method.
Johnny, run!!!
FIG. 1.15
Sending a
Message to
the Dog
Object to
Invoke its
Run Method
Note that we could have sent the same message to the horse object as well.
That would cause the horse to run, instead of the dog running. In effect,
different objects can have the same method and can receive the same message
from the external world. Their responses would also be quite similar to each
other. What would differ, though, is the precise execution of these methods.
However, this discussion raises another question. How do we know in the
first place that a dog or a horse can run? (In real life, we would actually know
this!) But consider another object called as employee. Let us imagine that we
Copyright © 2004. Tata McGraw-Hill. All rights reserved.
Many times,
the list of
are interested in finding out the salary of the employee. What message do we
methods of an need to send to the employee object, so that it can provide us with this infor-
object is mation? We cannot take for granted or hope that the employee object contains
called as the a method for this purpose. As a result, every object must inform the external
interface of
the object. world which methods it provides. In the absence of this, it is not possible for
other objects in the system to send it any messages. The idea to achieve this
objective is actually quite straightforward. Every object must publish a list of
methods that it supports. This enables other objects to consult this list, and
send it appropriate messages. This concept is shown in Fig. 1.16.
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
An Introduction to Object Technology 13
FIG. 1.16
List of
Methods
Published by
the Dog
Object I Can Run
If we consider two objects X and Y, we can imagine that object X can send a
message to object Y. This can be for requesting it to execute one of its meth-
ods. Similarly, object Y can invoke any method of object X by sending it a
message, as shown in Fig. 1.17.
Object X
Method 1 Method 2
Copyright © 2004. Tata McGraw-Hill. All rights reserved.
FIG. 1.17
Method 1 Method 2
Objects Send
Messages to
Each Other to Data Data Data Data
Call Each
Object Y
Other’s
Methods
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
14 Object Oriented Analysis and Design
The diagram also illustrates a very critical concept. Objects can call the
methods of other objects by sending messages to each other. However, an
object does not have any direct access to the data portion of another object. An
object protects or hides its data from the outside world. On the other hand, it
publishes data to the entire world. In the real world, there are minor variations
of this concept. For the time being, it is safe to imagine that an object protects
its data, and does not allow another object to access it. However, it exposes its
methods to everyone else so that they can call any of those methods.
We have been discussing the significant effects of global data in the proce-
Access dural technology. Providing for common data access to more than one program
specifiers almost always leads to some sort of problems. Object technology makes the
such as
private,
boundaries between different objects quite crisp and explicit in relation to the
protected, and data items. Since objects are supposed to be self-sufficient entities, it is very
public are important that their internal details are protected from other objects. Other-
used for this; wise, this self-sufficient nature of objects may be in danger. It is, therefore,
as we shall
study later. quite essential to protect the internal details of objects from other objects.
We hear the term object orientation quite often in the context of object
technology. Object orientation is used for modeling a system. This can be
applied to various aspects of a computer system, such as analysis and design
models, programs, test cases, databases, architecture, etc. Object orientation is
a completely different and novel way of thinking about a system as compared
to the traditional systems.
The point to be stressed here is that we talk of objects, and how they interact
with each other. The computer system that we want to ultimately build would
be based on these objects and their interaction with each other. Thus, objects
would consider other objects as self-contained entities, which can receive mes-
sages and perform appropriate actions. This idea is shown in Fig. 1.18.
We will note that the big advantage of this scheme is the least differences in
the way we imagine the various objects (e.g. students, teacher, books, school)
Copyright © 2004. Tata McGraw-Hill. All rights reserved.
and the way they can actually be modeled by using a computer-based system.
We now think of computer objects in the same way as real-world objects. This
is really revolutionary. Recall that otherwise the analysts and designers are
generally forced to think in terms of computer-based entities, such as net-
works, databases, programs, etc. right from the inception of a software project.
Here, they can think of real-world objects as, well, objects! The gap between
what we perceive and how we model it is called as the semantic gap between
the two. As we can see, the semantic gap in the case of traditional procedure-
based systems is quite high, but it is remarkably small in the case of object
technology.
This is shown in Fig. 1.19.
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
An Introduction to Object Technology 15
Students Meena and Seema ask their teacher Ana about their doubts
FIG. 1.18
Interaction
between
Real-World They also read books and study in the same school
Objects
Outside World
Outside World
Actual Implementation
Actual Implementation
FIG. 1.19
Procedural systems: The semantic Object-oritented systems: The
Copyright © 2004. Tata McGraw-Hill. All rights reserved.
The smaller the semantic gap, the better. This is because a smaller semantic
gap means that there is a small difference between the way we perceive a
computer system and how it is actually built.
There are two main advantages of a making the semantic gap small.
1. It makes understanding the system’s requirements and modeling easy,
and
2. It makes the process of alterations to software easy.
The second point is key, because a smaller semantic gap means that objects
are as much self-contained as possible, and therefore, changes to one object do
not greatly affect other objects in the system.
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
16 Object Oriented Analysis and Design
Based on our discussion so far, let us think of an object in real life. So far, we
have talked of objects that are abstract in nature, and have no real significance
in computer-based systems. It is now time that we put this discussion to some
Modeling is
quite similar
practical use.
to finding We have mentioned that an object is a self-contained unit. It contains at-
answers to tributes and methods. The attributes of an object are private to that object, and
such are closely guarded from other objects. That is, other objects cannot access or
questions.
modify the attributes of this object. However, the methods of an object are
publicly available to other objects for execution requests.
Let us put these theories to the use of creating an employee object. This
object needs to store information about the employees in an organization, and
also to allow other objects to manipulate its contents by calling its methods.
What are the typical pieces of information that we want to store about an
employee? These would form the attributes of the employee object. Quite
clearly, these attributes are employee number, name, department, manager,
salary, and address.
Next, we need the other objects to be able to access and manipulate the
details of this employee object. This means that we need to provide a few
methods that the employee object uses as its interface with the external world.
These methods need to create a bridge between the employee object and the
other objects in the system. As a very simple example, these methods should
provide the other objects the details about the attributes of the employee ob-
ject, such as the employee number, name, address, department, etc. as and
when needed.
Thus, our set of attributes and methods of the employee object is now
complete. They are listed as shown in Fig. 1.20.
Employee Object
Attributes Methods
l Number l getName
Copyright © 2004. Tata McGraw-Hill. All rights reserved.
l Name l getSalary
l Salary l getDepartment
FIG. 1.20 l Department l getAddress
l Address
Employee
Object
This object should give us a fairly good idea regarding the look-and-feel of
real-life objects. In fact, the code written to declare an employee object in an
object-oriented language, such as Java or C++ is actually not dramatically
different from the way we have written it here!
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
An Introduction to Object Technology 17
1.2.4 Classes
Thus far, we have discussed the idea of objects. Objects are specific in nature.
However, they can be generalized, too. When objects are generalized, they
make up a class. A class is generic in nature, whereas objects are specific
Classes are
generic,
instances of a class. For example, circle, rectangle, square, are all geometric
objects are diagrams. These are objects, whereas figure can be a generic class. Similarly,
specific. Ram, Sham, Ana, Jui, Harsh, are all specific objects, whereas person is a
generic class. Yet another example of specific objects are train, airplane, truck,
car, scooter, etc. The generic class for these objects is vehicle.
Thus, objects are specific instances of class, which is a generic template for
those objects.
This idea is shown in Fig. 1.21 with the example of a diagram class that has
geometric objects as specific instances.
Diagram
Class
Rectangle Octagon
Object Object Circle
Right Object
Triangle
Object
Trapezoid
FIG. 1.21 Object
Isosceles
Class and Triangle
Object
Objects
Copyright © 2004. Tata McGraw-Hill. All rights reserved.
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
18 Object Oriented Analysis and Design
can use these basic concepts for declaring classes and objects as well. Just
imagine for a moment that int and float are classes, and i and f are objects of
these two classes, respectively. Extending this idea further, can we declare an
object (say triangle) for the diagram class? The following statement in Java or
C# should achieve it.vehicle car;
diagram triangle;
Thus, we have understood a very important concept, as shown in Fig. 1.22.
Class Object
FIG. 1.22 int i
float f
Classes and diagram triangle
Objects
This idea should help us understand the relationship between classes and
objects very clearly. Just as integers, floating-point numbers, etc. are generic
templates (i.e. classes), so can be other types, such as vehicle, student, person, etc.
For each such class, we can declare one or more specific instances (i.e. objects).
This description does not end our story here. It goes further and tells us a lot
more about classes and objects. A class has general properties, which all of its
objects automatically absorb and inherit. For example, when we think about an
Data types
such as int, we immediately think of it to be a number that cannot have fractional part,
integers, or a value exceeding a maximum number, etc. Therefore, when we declare any
characters, number (say i) as an integer, it obeys all these restrictions by default. Extend-
strings etc.
are called as
ing this concept further, when we declare an employee class and jui as an
primitive or object of this employee class, jui automatically picks up all the default charac-
basic data teristics of the employee class, such as number, name, department, etc.
types.
Let us now revisit the question of how to declare classes and objects in a
programming language, such as Java or C#. For that, let us consider the same
Copyright © 2004. Tata McGraw-Hill. All rights reserved.
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
An Introduction to Object Technology 19
FIG. 1.23
string int float …
Class
contains
many basic Class
data types
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
20 Object Oriented Analysis and Design
1.3 ABSTRACTION
language would contain instructions such as ADD, COPY, MOVE, etc. (or
Always their equivalents). Let us consider the example of an instruction MOVE B
remember TO A, which means copy the contents of the variable B to the variable A.
that ultimately l The assembly language is at a lower level in the sense that one instruction
the computer
hardware can in a high-level language maps to one or more assembly language instruc-
only execute tions. For instance, a MOVE instruction in a high-level language could
machine result into multiple assembly language instructions, such as LOAD and
language
instructions.
STORE.
l Next, each assembly language instruction is translated to its corresponding
machine language code. This is the language of zeroes and ones.
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
An Introduction to Object Technology 21
lIn the end, the machine language abstracts the voltages and current pulses
inside a computer, and provides a language of zeroes and ones to the
programmer.
This concept is shown in Fig. 1.25.
LOAD R3
Assembly Language Level
STORE R1
10101111010
FIG. 1.25 Machine Language Level 10010010010
Abstraction in
Programming Hardware Level … Language of Currents and Voltages …
Languages
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
22 Object Oriented Analysis and Design
Window of the
Cashiner
Abstraction
In Out
can be Used
to Generalize
Similar Ideas Generic Mechanism of Representing these as a Queue
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
An Introduction to Object Technology 23
1.4 ENCAPSULATION
object for creating a new employee record and updating some of the fields.
This can be as shown in Fig. 1.27.
As the Fig 1.28 shows, a student object gives the view of a black box. It
tells the outside world that its interface is made up of two methods: new and
modify. How they work internally is not known. In fact, hardly anything else is
Messaging
facilitates known about the employee object apart from these two method names. To
inter-object update the mark details of a student, for instance, the modify method must be
communication. called. To that method, the new address should be passed. That is the whole
idea. Other objects need not know anything about the internal structure of the
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
24 Object Oriented Analysis and Design
New Modify
Student
FIG. 1.27
Encapsulation
FIG. 1.28
Pay
Encapsulation
Enables Cardholder Merchant
Message Receipt
Exchanges
between
Objects
student object. That way, the internal structure of the student object can be
changed without affecting other objects.
This concept is shown in Fig. 1.28 with another example. Here, a credit card
object sends a message pay to the card object. This will cause the transfer of
funds from the card account to the merchant account. The cardholder object
does not know how the merchant object works internally. However, the
cardholder object performs the action (i.e. transfer of funds) successfully and
returns an acknowledgement in the form of a receipt to the cardholder object.
This is precisely what the cardholder object expects, anyway!
Thus, the main idea of encapsulation is hiding of internal details of an
object. Essentially, we keep the internal details of an object clearly distinct
from its external view. This also means that the changes to the internal details
of one object do not cause many rippling changes to other objects in the
Copyright © 2004. Tata McGraw-Hill. All rights reserved.
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
An Introduction to Object Technology 25
knows how it can interact with any other object (by calling its methods), this
does not impose any limitations on the interaction between objects.
An interesting way to depict encapsulation is shown in Fig. 1.29. Here, we
show an object that has certain attributes, and it possesses certain methods.
The attributes portion is completely hidden from the outside world. This is
indicated by mentioning the attributes that are hidden (which is what the out-
side world sees). However, the object has a border consisting of methods,
which allow other objects to interact with it, by sending messages.
Message
Method Method
Method
Attributes
Message Hidden Message
Inside
Method
FIG. 1.29
Message
Another Way
to Depict
Abstraction
The term Object Oriented Analysis and Design (OOAD) was coined in order
to differentiate it from the classical analysis and design techniques, such as
OOAD is a Structured System Analysis and Design (SSAD) and the Jackson Methodol-
concept, but it ogy. OOAD has attracted a lot of interest in the last few years, and in fact, it
can be has almost become the de facto standard for majority of newly undertaken
applied in
Copyright © 2004. Tata McGraw-Hill. All rights reserved.
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
26 Object Oriented Analysis and Design
Requirements
Analysis
Design
Development
Testing
FIG. 1.30
Phases in a
Software Implementation
Project
OOAD has evolved over several years. There have been many methodolo-
gies that have been proposed. OOAD as it stands today is actually a mixture of
these methodologies. We shall discuss some of the main OOAD methodologies
One of the
biggest
in brief. This will provide us a good background in terms of understanding
problems with how and why OOAD is the way it is today. Of the people who have done solid
the different groundwork in the area of OOAD are Grady Booch, Evor Jacobson, and James
methodologies
Rumbaugh. Their methodologies are still studied separately to gain an insight
is that they
use different into their work. However, more often, a combination of these methods is now
symbols to studied and applied, as it combines the best features of all of them.
depict the Our focus would be to present a brief yet crisp overview of these method-
same thing.
ologies, and in the later chapters, show how these converge to a single method
called as Rational Unified Process (RUP).
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
An Introduction to Object Technology 27
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
28 Object Oriented Analysis and Design
Class name
Attributes
Operations ( )
{Constraints}
FIG. 1.31
Class Symbol
Ä Abstraction
Abstraction denotes the essential characteristics of an object that distinguish it
from all other kinds of objects. Furthermore, it provides crispy defined concep-
All OOAD
tual boundaries, relative to the perspective of the viewer. Booch recommends
methodologies that the designer identify these boundaries as soon as possible, and that the
talk about programming languages that transform this design into actual code should also
these general respect these boundaries, and implement them. For this purpose, it is important
concepts, and
hence we need to identify four important artifacts of a system:
not repeat the (a) Instance methods These methods are accessible to any object (i.e. any
discussion for
all of them. instance) of a class.
(b) Instance attributes These attributes are accessible to any object (i.e.
any instance) of a class.
(c) Class attributes These attributes are accessible to all the objects (i.e. all
the instances) of a class, but all the instances share the same value of a
given attribute.
(d) Class methods These methods are accessible to all the objects (i.e. all
the instances) of a class, but they all can be used independently of any object.
Ä Modularity
Modularity is the property of a system that has been decomposed into a set of
cohesive and loosely coupled modules. In other words, the programming imple-
mentation of an object-oriented design should provide for the classification of
Copyright © 2004. Tata McGraw-Hill. All rights reserved.
related classes and objects into packages or files. This helps in terms of a
better organization and logical referencing of classes.
Ä Encapsulation
Encapsulation is the process of hiding all the details of an object that do not
contribute to its essential characteristics. That is, the designer should classify
the attributes and methods of a class into various categories:
(a) Private Those attributes and methods that should belong only to the
class and no other class should even know about their existence.
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
An Introduction to Object Technology 29
(b) Protected Those attributes and methods that also belong to a class and
should only be known to that class, but with one exception. When the class
is inherited by another class, the child class can also access these attributes
This will be
clear when we
and methods.
discuss (c) Public Those attributes and methods that are declared in a class, but are
inheritance.
globally accessible to all the other classes in the system.
Ä Hierarchy
Hierarchy builds an order or a rank of the various abstractions. This is mainly
implemented in the form of inheritance relationships, which can go down to
multiple levels.
Ä Typing
Typing is the enforcement of a class of an object in such a way that objects of
different type may not be swapped. At the most, they might be swapped in
very restricted manners.
Ä Concurrency
Concurrency distinguishes one object that is active from an inactive object.
Ä Persistence
Persistence is the characteristic of an object through which it always exists.
Persistence
means storing That is, even when the creator of an object no longer exists, the object contin-
on the disk. ues to exist.
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
30 Object Oriented Analysis and Design
Thus, we begin by identifying the users of the system, here called as actors.
These actors can be human or non-human. For example, a person preparing
pay-slips is a human actor. On the other hand, a scanner digitizing a document
is an example of a non-human actor. Having identified the actors, we then
identify what tasks each of these actors would perform (i.e. the use cases).
Then we create a relationship between the actors and the use cases. Finally, we
create scenarios to validate these relationships. Thus, we can summarize:
l Identify interface objects by using information about actors and their inter-
actions
l Create structural views of the interface objects
l Represent object behaviour (i.e. methods)
l Isolate subsystems and models for all of them
l Review the model by using use cases as scenarios to determine validity
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
An Introduction to Object Technology 31
Ä Inception
This step deals with the initial high-level planning of the project. We deter-
We shall mine the scope of the project here. We also discuss some of the business
discuss this in decisions and their impacts. Other factors such as costing, estimation, and
a separate
chapter.
projected revenue also come into picture.
Ä Elaboration
This step primarily deals with the requirements gathering, analysis, and design
phases of a project. We also develop an outline for the construction phase of
the project here. The risks pertaining to the project are also identified and a
risk mitigation plan prepared. The risks can be of various natures, such as
technological, business-related, political, skills-related, requirements-related,
etc. The resulting artifacts of the elaboration phase are use cases, the domain
and technology models, and the risk mitigation plan.
Ä Construction
In this phase, the use cases are transformed into actual program code. It is
quite possible that the analysis and design steps get refined here, as more
clarity is needed in order to perform the actual construction activities. Soft-
ware testing also plays a crucial role. The product should be tested as much
and as early as possible.
Ä Transition
This is the phase just before the main release of a software product. Here,
things like scalability, optimization, performance etc. are primarily addressed.
Copyright © 2004. Tata McGraw-Hill. All rights reserved.
The fountain model depicts the essence of OOAD. It is a diagram that re-
minds us about the fact that although some life cycle activities cannot start
before others (e.g. we cannot start coding before we have started designing),
there is a considerable overlap and combining of activities across the full
software life cycle.
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
32 Object Oriented Analysis and Design
Evolution
Maintenance
Program
Use
System
Testing
Unit Testing
Coding
Component
Design
Conceptual
Design
Analysis
Copyright © 2004. Tata McGraw-Hill. All rights reserved.
Requirements and
Feasibility Study
FIG. 1.32
Software Pool
Fountain
model
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
An Introduction to Object Technology 33
CHAPTER SUMMARY
n Traditionally, focus was on hardware. Over the last few years, it has changed to
software.
n Software projects have become extremely complex and costly. Hence, older
methodologies are no longer advisable.
n The earliest software approach was on the basis of procedural programming.
n Modular programming came later, where the programs were divided into smaller,
more manageable modules.
n Object technology is a newer method of designing and developing software.
n Object technology introduces the concept of an object. An object contains both
data (called as the attributes of an object) and its functionalities (called as meth-
ods).
n Objects interact with each other by passing messages.
n Generic form of objects, i.e. a template for similar kinds of objects is called as
class.
n Abstraction is an important concept in object technology. It allows the designer
to focus on the significant concepts and ignore unimportant details.
n Encapsulation protects the data in an object.
n The term Object Oriented Analysis and Design (OOAD) was coined in order to
differentiate it from the classical analysis and design techniques, such as Struc-
tured System Analysis and Design (SSAD) and the Jackson Methodology.
n OOAD has evolved over several years.
n The early efforts in OOAD can be attributed to Grady Booch, Ivar Jacobson, and
James Rumbaugh.
n Of late, a combination of these methodologies has become popular, called as the
Rational Unified Proecss (RUP) model.
n The fountain model provides some insights into the working of OOAD.
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
34 Object Oriented Analysis and Design
PRACTICE EXERCISES
True/False Questions
1. Software has always been more important than hardware.
2. Modular programming came after procedural programming.
3. An attribute has no consequence in the object technology world.
4. A method is similar to a function.
5. Class is a generic template for objects.
6. Abstraction is the same as inheritance.
7. An object contains only attributes.
8. Modeling is important to the object world.
9. RUP is a combination of the best of all OOAD methods.
10. The fountain model helps depict the OOAD process.
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.
An Introduction to Object Technology 35
Detailed Questions
1. What is the software crisis?
2. What is the problem with traditional software development?
3. Define procedural programming.
4. What is modular programming?
5. Discuss the concept of an object.
6. What is a class?
7. Explain the idea of abstraction.
8. What is encapsulation?
9. Discuss any of the OOAD approaches.
10. What is RUP?
Copyright © 2004. Tata McGraw-Hill. All rights reserved.
Kahate, Atul. Object Oriented Analysis & Design, Tata McGraw-Hill, 2004. ProQuest Ebook Central, http://ebookcentral.proquest.com/lib/inflibnet-ebooks/detail.action?docID=5121208.
Created from inflibnet-ebooks on 2020-10-19 23:20:41.