Unit - 1 Q-Explain Object Oriented Development Life Cycle?
Unit - 1 Q-Explain Object Oriented Development Life Cycle?
Unit - 1 Q-Explain Object Oriented Development Life Cycle?
or
Q-1. Explain object oriented methodology ?
Ans: We live in a world of objects. These objects exist in nature, in man-made entities, in business, and
in the products that we use. They can be categorized, described, organized, combined, manipulated and
created. Therefore, an object-oriented view has come into picture for creation of computer software. An
object-oriented approach to the development of software was proposed in late 1960s.
Object-Oriented development requires that object-oriented techniques be used during the analysis, and
implementation of the system. This methodology asks the analyst to determine what the objects of the
system are, how they behave over time or in response to events, and what responsibilities and
relationships an object has to other objects. Object-oriented analysis has the analyst look at all the
objects in a system, their commonalties, difference, and how the system needs to manipulate the
objects.
OOM is a new system development approach encouraging and facilitating re-use of software
components. With this methodology, a computer system can be developed on a component basis which
enables the effective re-use of existing components and facilitates the sharing of its components by
other systems. Through the adoption of OOM, higher productivity, lower maintenance cost and better
quality can be achieved.
Object Oriented Process
The Object Oriented Methodology of Building Systems takes the objects as the basis. For this, first the
system to be developed is observed and analyzed and the requirements are defined as in any other
method of system development. Once this is done, the objects in the required system are identified. For
example in case of a Banking System, a customer is an object, a chequebook is an object, and even an
account is an object.
The object model of a bank . The boxes represent classes and the filled triangle represents
specialization. Association B/w Account and transaction is one to many; since one account have many
transaction, the filled circle many (zero or more). The relationship b/w Client and Account class is one to
one: A Client can have only one account and account can belong to only one person.
In simple terms, Object Modeling is based on identifying the objects in a system and their
interrelationships. Once this is done, the coding of the system is done. Object Modeling is somewhat
similar to the traditional approach of system designing, in that it also follows a sequential process of
system designing but with a different approach. The basic steps of system designing using Object
Modeling may be listed as:
System Analysis
System Design
Object Design
Implementation
System Analysis
As in any other system development model, system analysis is the first phase of development in case of
Object Modeling too. In this phase, the developer interacts with the user of the system to find out the
user requirements and analyses the system to understand the functioning.
Based on this system study, the analyst prepares a model of the desired system. This model is purely
based on what the system is required to do. At this stage the implementation details are not taken care
of. Only the model of the system is prepared based on the idea that the system is made up of a set of
interacting objects. The important elements of the system are emphasized.
System Design
System Design is the next development stage where the overall architecture of the desired system is
decided. The system is organized as a set of sub systems interacting with each other. While designing
the system as a set of interacting subsystems, the analyst takes care of specifications as observed in
system analysis as well as what is required out of the new system by the end user.
As the basic philosophy of Object-Oriented method of system analysis is to perceive the system as a set
of interacting objects, a bigger system may also be seen as a set of interacting smaller subsystems that
in turn are composed of a set of interacting objects. While designing the system, the stress lies on the
objects comprising the system and not on the processes being carried out in the system as in the case of
traditional Waterfall Model where the processes form the important part of the system.
Object Design
In this phase, the details of the system analysis and system design are implemented. The Objects
identified in the system design phase are designed. Here the implementation of these objects is decided
as the data structures get defined and also the interrelationships between the objects are defined.
Let us here deviate slightly from the design process and understand first a few important terms used in
the Object-Oriented Modeling.
As already discussed, Object Oriented Philosophy is very much similar to real world and hence is gaining
popularity as the systems here are seen as a set of interacting objects as in the real world. To implement
this concept, the process-based structural programming is not used; instead objects are created using
data structures. Just as every programming language provides various data types and various variables
of that type can be created, similarly, in case of objects certain data types are predefined.
For example, we can define a data type called pen and then create and use several objects of this data
type. This concept is known as creating a class.
Class: A class is a collection of similar objects. It is a template where certain basic characteristics of a
set of objects are defined. The class defines the basic attributes and the operations of the objects of that
type. Defining a class does not define any object, but it only creates a template. For objects to be
actually created instances of the class are created as per the requirement of the case.
Abstraction: Classes are built on the basis of abstraction, where a set of similar objects are observed
and their common characteristics are listed. Of all these, the characteristics of concern to the system
under observation are picked up and the class definition is made. The attributes of no concern to the
system are left out. This is known as abstraction.
The abstraction of an object varies according to its application. For instance, while defining a pen class
for a stationery shop, the attributes of concern might be the pen color, ink color, pen type etc., whereas
a pen class for a manufacturing firm would be containing the other dimensions of the pen like its
diameter, its shape and size etc.
Inheritance: Inheritance is another important concept in this regard. This concept is used to apply the
idea of reusability of the objects. A new type of class can be defined using a similar existing class with a
few new features. For instance, a class vehicle can be defined with the basic functionality of any vehicle
and a new class called car can be derived out of it with a few modifications. This would save the
developers time and effort as the classes already existing are reused without much change.
Coming back to our development process, in the Object Designing phase of the Development process,
the designer decides onto the classes in the system based on these concepts. The designer also decides
on whether the classes need to be created from scratch or any existing classes can be used as it is or
new classes can be inherited from them.
Implementation
During this phase, the class objects and the interrelationships of these classes are translated and
actually coded using the programming language decided upon. The databases are made and the
complete system is given a functional shape.
The complete OO methodology revolves around the objects identified in the system. When observed
closely, every object exhibits some characteristics and behavior. The objects recognize and respond to
certain events. For example, considering a Window on the screen as an object, the size of the window
gets changed when resize button of the window is clicked.
Here the clicking of the button is an event to which the window responds by changing its state from the
old size to the new size. While developing systems based on this approach, the analyst makes use of
certain models to analyze and depict these objects. The methodology supports and uses three basic
Models:
Object Model - This model describes the objects in a system and their interrelationships. This model
observes all the objects as static and does not pay any attention to their dynamic nature.
Dynamic Model - This model depicts the dynamic aspects of the system. It portrays the changes
occurring in the states of various objects with the events that might occur in the system.
Functional Model - This model basically describes the data transformations of the system. This
describes the flow of data and the changes that occur to the data throughout the system.
While the Object Model is most important of all as it describes the basic element of the system, the
objects, all the three models together describe the complete functional system.
As compared to the conventional system development techniques, OO modeling provides many
benefits. Among other benefits, there are all the benefits of using the Object Orientation. Some of these
are:
Reusability - The classes once defined can easily be used by other applications. This is achieved by
defining classes and putting them into a library of classes where all the classes are maintained for future
use. Whenever a new class is needed the programmer looks into the library of classes and if it is
available, it can be picked up directly from there.
Inheritance - The concept of inheritance helps the programmer use the existing code in another way,
where making small additions to the existing classes can quickly create new classes.
Programmer has to spend less time and effort and can concentrate on other aspects of the system due
to the reusability feature of the methodology.
Data Hiding - Encapsulation is a technique that allows the programmer to hide the internal functioning
of the objects from the users of the objects. Encapsulation separates the internal functioning of the
object from the external functioning thus providing the user flexibility to change the external behaviour
of the object making the programmer code safe against the changes made by the user.
The systems designed using this approach are closer to the real world as the real world functioning of
the system is directly mapped into the system designed using this approach.
Advantages of procedural programming1-Its relative simplicity, and ease of implementation of compilers and interpreters .
2- The ability to re-use the same code at different places in the program without copying it.
3-An easier way to keep track of program flow.
4-The ability to be strongly modular or structured.
5-Needs only less memory.
In a procedural-based programming language, a programmer writes out instructions that are followed
by a computer from start to finish. This kind of programming had its own advantages, but an OOP makes
programming more clearer and easier to understand as. Object-oriented programming is all about using
objects.
An object actually contains code (member functions) and data (data members) where the code and data
have been kept apart. For example, in the C language, units of code are called functions, while units of
data are called structures. Functions and structures are not formally connected in C. A C function can
operate on more than one type of structure, and more than one function can operate on the same
structure.
The main difference of OOP with procedural language are:
a) Object Orientation Languages objective is to develop an application based on real time while
Procedural Programming Languages(PPL) are more concerned with the processing of procedures or
functions.
b) In OOP, more emphasis is given on data rather than procedures, while the programs are divided into
objects and the data is encapsulated (i.e. hidden) from the external environment, providing more
security to data which is not generaly applicable or rather possible in PPL like C.
c) In OOP, Objects communicate with each other via functions ,while there is no explicit communication
in PPL rather its simply a passing values to the arguments to the functions.
d) OOP follows bottom up approach of program execution while in PPL its top down approach.
e) OOPs concepts includes Inheritance, Encapsulation and Data Abstraction, Polymorphism,
Multithreading, and Message Passing while PPL is simply a programming in a traditional way of calling
functions and returning values.PPL does not suport it.
return 0;
#include <iostream>
using namespace std;
class Mathematics {
int x, y;
public:
void input() {
cout << "Input two inetegers\n";
cin >> x >> y;
}
void add() {
cout << "Result = " << x + y;
}
};
int main()
{
Mathematics m; // Creating object of class
m.input();
m.add();
return 0;
}
Divided Into
calledfunctions.
Importance
done.
world.
Approach
Access
Specifiers
Data Moving
Expansion
Data Access
Data Hiding
Overloading
easy.
function.
POP does not have any proper way for hiding data
so it is less secure.
security.
Examples
Types of Inheritance
In C++, we have 5 different types of Inheritance. Namely,
Single Inheritance
Multiple Inheritances
Hierarchical Inheritance
Multilevel Inheritance
Hybrid Inheritance (also known as Virtual Inheritance)
Single Inheritance
In this type of inheritance one derived class inherits from only one base class. It is the most simplest
form of Inheritance.
Multiple Inheritance
In this type of inheritance a single derived class may inherit from two or more than two base classes.
Hierarchical Inheritance
In this type of inheritance, multiple derived classes inherits from a single base class.
Multilevel Inheritance
In this type of inheritance the derived class inherits from a class, which in turn inherits from some other
class. The Super class for one, is sub class for the other.
protected:
float length, breadth;
public:
Rectangle(): length(0.0), breadth(0.0)
{
cout<<"Enter length: ";
cin>>length;
cout<<"Enter breadth: ";
cin>>breadth;
}
};
/* Area class is derived from base class Rectangle. */
class Area : public Rectangle
{
public:
float calc()
{
return length*breadth;
}
};
/* Perimeter class is derived from base class Rectangle. */
class Perimeter : public Rectangle
{
public:
float calc()
{
return 2*(length+breadth);
}
};
int main()
{
cout<<"Enter data for first rectangle to find area.\n";
Area a;
cout<<"Area = "<<a.calc()<<" square meter\n\n";
cout<<"Enter data for second rectangle to find perimeter.\n";
Perimeter p;
cout<<"\nPerimeter = "<<p.calc()<<" meter";
return 0;
}