Module 1 Chapter 1
Module 1 Chapter 1
Introduction
Object-oriented methodology (OOM) is a system development approach that allows for the reuse of
software components. It's a way of viewing software components and their relationships, and is
based on three characteristics: encapsulation, polymorphism, and inheritance.
It employs international standard Unified Modeling Language (UML) from the Object
Management Group (OMG).
Using this methodology, a system can be developed on a component basis, which enables
the effective re-use of existing components, it facilitates the sharing of its other system
components.
Object Oriented Methodology asks the analyst to determine what the objects of the system
are?, What responsibilities and relationships an object has to do with the other objects? and
How they behave over time?
Advantages of C++
1. Portability
C++ offers the feature of portability or platform independence which allows the user to run the
same program on different operating systems or interfaces at ease.
Suppose you write a program in LINUX OS and for some apparent reason you switch to Windows OS,
you would be able to run the same program in windows as well without any error. This feature
proves to be of great convenience to the programmer.
2. Object-oriented
One of the biggest advantages of C++ is the feature of object-oriented programming which includes
concepts like classes, inheritance, polymorphism, data abstraction, and encapsulation that allow
code reusability and makes a program even more reliable.
Not only this, it helps us deal with real-world problems by treating data as an object. C lacked this
feature and hence it was created, proving to be of great significance.
This feature gave birth to numerous job prospects and technologies. It is fascinating to note that C++
was created by combining features not only from C but Simula 67, the first object-oriented
programming language.
3. Multi-paradigm
C++ is a multi-paradigm programming language. The term “Paradigm” refers to the style of
programming. It includes logic, structure, and procedure of the program. Generic, imperative, and
object-oriented are three paradigms of C++.
Let us now try to understand what generic programming means. Generic programming refers to the
use of a single idea to serve several purposes. Imperative programming, on the other hand, refers to
the use of statements that change a program’s state.
4. Low-level Manipulation
Since C++ is closely associated with C, which is a procedural language closely related to the machine
language, C++ allows low-level manipulation of data at a certain level. Embedded systems and
compiler are created with the help of C++.
5. Memory Management
C++ gives the programmer the provision of total control over memory management. This can be
considered both as an asset and a liability as this increases the responsibility of the user to manage
memory rather than it being managed by the Garbage collector. This concept is implemented with
the help of DMA (Dynamic memory allocation) using pointers.
C++ has a large community that supports it by providing online courses and lectures, both paid and
unpaid. Statistically speaking, C++ is the 6th most used and followed tag on StackOverflow and
GitHub.
7. Compatibility with C
C++ is pretty much compatible with C. Virtually, every error-free C program is a valid C++ program.
Depending on the compiler used, every program of C++ can run on a file with .cpp extension.
8. Scalability
Scalability refers to the ability of a program to scale. It means that the C++ program is capable of
running on a small scale as well as a large scale of data. We can also build applications that are
resource intensive.
Disadvantages of C++
1. Use of Pointers
Pointers in C/C++ are a relatively difficult concept to grasp and it consumes a lot of memory. Misuse
of pointers like wild pointers may cause the system to crash or behave anomalously.
2. Security Issue
Although object-oriented programming offers a lot of security to the data being handled as
compared to other programming languages that are not object-oriented, like C, certain security
issues still exist due to the availability of friend functions, global variables and, pointers.
As discussed earlier, C++ gives the user complete control of managing the computer memory using
DMA. C++ lacks the feature of a garbage collector to automatically filter out unnecessary data.
Application of OOPS
What is Class?
A class is an entity that determines how an object will behave and what the object will contain. In
other words, it is a blueprint or a set of instruction to build a specific type of object. It provides initial
values for member variables and member functions or methods.
What is Object?
An object is nothing but a self-contained component that consists of methods and properties to
make a data useful. It helps you to determines the behavior of the class.
For example, when you send a message to an object, you are asking the object to invoke or execute
one of its methods.
From a programming point of view, an object can be a data structure, a variable, or a function that
has a memory location allocated. The object is designed as class hierarchies.
Class vs Object – Difference Between Them
Let’s take an example of developing a pet management system, specially meant for dogs. You will
need various information about the dogs like different breeds of the dogs, the age, size, etc.
You need to model real-life beings, i.e., dogs into software entities.
Moreover, the million dollar question is, how you design such software? Here is the solution-
You can see the picture of three different breeds of dogs below.
Stop here right now! List down the differences between them.
Some of the differences you might have listed out maybe breed, age, size, color, etc. If you think
for a minute, these differences are also some common characteristics shared by these dogs. These
characteristics (breed, age, size, color) can form a data members for your object.
Next, list out the common behaviors of these dogs like sleep, sit, eat, etc. So these will be the
actions of our software objects.
So far we have defined following things,
Class: Dogs
Encapsulation: the attributes of an entity are enclosed in itself. In other words, encapsulation is
when an object (inside a class) keeps its state private and only exposes the selected information. This
principle requires the ability to define some fields as either private or public.
Abstraction: hide important information in order to reduce complexity. It is when the user only
interacts with specific object’s methods and/or attributes. By hiding complex details from the user,
abstraction consequently reduces complexity.
Inheritance: as the name indicates, an entity can inherit attributes from other entities. More
precisely, parent classes can extend their attributes and behaviors to child classes, which also means
that this principle supports reusability.
Polymorphism: entities can have more than one form. Hence the ‘poly’. In sum, polymorphism is
when objects are designed to share behaviors. By overriding or overloading, the same method can
perform different behaviours.