Unit 1 - Concepts of Object Oriented Programming
Unit 1 - Concepts of Object Oriented Programming
LECTURE NOTES
II SEMESTER
Regulation – 2022
Academic Year 2023 – 2024(Even Semester)
Prepared by
Abstract data type (ADT) is a concept or model of a data type. Because of ADT, a user doesn’t
have to bother about how that data type has been implemented. Moreover, ADT also takes care of
the implementation of the functions on a data type. Here, the user will have predefined functions on
each data type ready to use for any operation.
ADTs are a popular and important data type. Generally, ADTs are mathematical or logical concepts
that can be implemented on different machines using different languages. Furthermore, they’re very
flexible and don’t dependent on languages or machines.
There are mainly three types of ADTs:
Advantages:
Encapsulation: ADTs provide a way to encapsulate data and operations into a single unit,
making it easier to manage and modify the data structure.
Abstraction: ADTs allow users to work with data structures without having to know the
implementation details, which can simplify programming and reduce errors.
Data Structure Independence: ADTs can be implemented using different data structures,
which can make it easier to adapt to changing needs and requirements.
Information Hiding: ADTs can protect the integrity of data by controlling access and
preventing unauthorized modifications.
Modularity: ADTs can be combined with other ADTs to form more complex data structures,
which can increase flexibility and modularity in programming.
Disadvantages:
Overhead: Implementing ADTs can add overhead in terms of memory and processing, which
can affect performance.
Complexity: ADTs can be complex to implement, especially for large and complex data
structures.
Learning Curve: Using ADTs requires knowledge of their implementation and usage, which can
take time and effort to learn.
Limited Flexibility: Some ADTs may be limited in their functionality or may not be suitable for
all types of data structures.
Cost: Implementing ADTs may require additional resources and investment, which can increase
the cost of development.
1.2 Inheritance
Inheritance is a fundamental concept in object-oriented programming (OOP), and it allows
you to create a new class that is based on an existing class.
This existing class is referred as the base class or parent class and the new class is called
the derived class or child class.
Inheritance facilitates code reusability and the creation of a hierarchical structure for classes.
1. Single Inheritance: In single inheritance, a derived class inherits from a single class.
2. Multiple Inheritance: In multiple inheritance, a derived class can inherit from multiple base
classes.
3. Multilevel Inheritance: In multilevel inheritance, a class inherits from a base class, and then
another class inherits from the derived classs, creating a chain.
4. Hierarchical Inheritance: In hierarchical inheritance, multiple classes inherit from a single base
class.
5. Hybrid Inheritance: Hybrid Inheritance is a combination of two or more types of inheritance.
1.3 Polymorphism
Polymorphism derived from Greek word poly (many) and morphe (form) means many
forms.
In C++, Polymorphism allows different classes to be treated uniformly through a common
base class.
This concept is divided into two types: compile time (static) polymorphism and runtime
(dynamic) polymorphism.
In object-oriented programming (OOP), objects are the basic entities that actually exists in
the memory.
Each object is based on a blueprint of attributes and behaviors (variables and functions)
defined as Class.
The basic purpose of a Class is to identify the common attributes and behaviors and group
them as an entity that can be reused again and again for similar purposes.
The Objects are such entities that are created based on these classes to follow that purpose.
All data members and member functions of the class can be accessed with the help of
objects.
When a class is defined, no memory is allocated, but memory is allocated when it is
instantiated (i.e. an object is created).
Example of Object
For Example, the objects for the class Account are SBI Account, ICICI account, etc.
Identity:
Every object must have a different identity from the other, known as the object’s name. No
two object must have the same name.
There are three main types of models that have been proposed by OMT:
i) Object Model
Object Model encompasses the principles of abstraction, encapsulation, modularity,
hierarchy, typing, concurrency and persistence.
Object Model basically emphasizes on the object and class.
Main concepts related with Object Model are classes and their association with
attributes.
Predefined relationships in object model are aggregation and generalization
(multiple inheritance).
ii) Dynamic Model
Dynamic Model involves states, events and state diagram (transition diagram) on the
model.
Main concepts related with Dynamic Model are states, transition between states and
events to trigger the transitions.
Predefined relationships in object model are aggregation (concurrency) and
generalization.
iii) Functional Model
Functional Model focuses on how data is flowing, where data is stored and different
processes.
Main concepts involved in Functional Model are data, data flow, data store, process
and actors.
Functional Model in OMT describes the whole processes and actions with the help
of data flow diagram (DFD).
1. Analysis
This is the first phase of the object modeling technique. This phase involves the preparation
of precise and correct modelling of the real world problems.
Analysis phase starts with setting a goal i.e. finding the problem statement.
Problem statement is further divided into above discussed three models i.e. object, dynamic
and functional model.
2. System Design
This is the second phase of the object modeling technique and it comes after the analysis
phase.
It determines all system architecture, concurrent tasks and data storage.
High level architecture of the system is designed during this phase.
3. Object Design
Object design is the third phase of the object modelling technique and after system design is
over, this phase comes.
Object design phase is concerned with classification of objects into different classes and
about attributes and necessary operations needed.
Different issues related with generalization and aggregation are checked.
4. Implementation
This is the last phase of the object modeling technique. It is all about converting prepared
design into the software.
Design phase is translated into the Implementation phase.
Class
A Class is a user-defined data type that has data members and member functions.
Data members are the data variables and member functions are the functions used to manipulate
these variables together these data members and member functions define the properties and
behaviour of the objects in a Class.
For Example: Consider the Class of Cars.
There may be many cars with different names and brands but all of them will share
some common properties like all of them will have 4 wheels, Speed Limit, Mileage
range, etc.
So here, the Car is the class, and wheels, speed limits, and mileage are their properties.
Object
An Object is an identifiable entity with some characteristics and behavior.
An Object is an instance of a Class. When a class is defined, no memory is allocated but when
it is instantiated (i.e. an object is created) memory is allocated.
A class is like a blueprint for an object.
Encapsulation
In normal terms, Encapsulation is defined as wrapping up data and information under a single
unit.
In Object-Oriented Programming, Encapsulation is defined as binding together the data and
the functions that manipulate them
Data abstraction
Data abstraction is one of the most essential and important features of object-oriented
programming in C++.
Abstraction means displaying only essential information and hiding the details.
Data abstraction refers to providing only essential information about the data to the outside
world, hiding the background details or implementation.
Abstraction using Classes:
We can implement Abstraction in C++ using classes.
The class helps us to group data members and member functions using available
access specifiers.
A Class can decide which data member will be visible to the outside world and which
is not.
Abstraction in Header files:
One more type of abstraction in C++ can be header files.
For example, consider the pow() method present in math.h header file.
Whenever we need to calculate the power of a number, we simply call the function
pow() present in the math.h header file and pass the numbers as arguments without
knowing the underlying algorithm according to which the function is actually
calculating the power of numbers.
C++
Java
C#
Visual Basic .NET
JavaScript
MATLAB
Object Pascal
Perl
PHP
Python
Objective-C
Swift
The ODBMS which is an abbreviation for object-oriented database management system is the
data model in which data is stored in form of objects, which are instances of classes. These classes
and objects together make an object-oriented data model.
1. Object Structure:
The structure of an object refers to the properties that an object is made up of.
These properties of an object are referred to as an attribute.
Thus, an object is a real-world entity with certain attributes that makes up the object
structure.
Also, an object encapsulates the data code into a single unit which in turn provides data
abstraction by hiding the implementation details from the user.
The object structure is further composed of three types of components: Messages, Methods,
and Variables. These are explained below.
1. Messages –
A message provides an interface or acts as a communication medium between an object and the
outside world. A message can be of two types:
Read-only message: If the invoked method does not change the value of a variable, then the
invoking message is said to be a read-only message.
Update message: If the invoked method changes the value of a variable, then the invoking
message is said to be an update message.
2. Methods –
When a message is passed then the body of code that is executed is known as a method.
Whenever a method is executed, it returns a value as output. A method can be of two types:
Read-only method: When the value of a variable is not affected by a method, then it is
known as the read-only method.
Update-method: When the value of a variable change by a method, then it is known as an
update method.
3. Variables –
It stores the data of an object. The data stored in the variables makes the object distinguishable
from one another.
2. Object Classes:
An object which is a real-world entity is an instance of a class.
Hence first we need to define a class and then the objects are made which
differ in the values they store but share the same class definition.
The objects in turn correspond to various messages and variables stored in
them.
An OODBMS also supports inheritance in an extensive manner as in a database there may be many
classes with similar methods, variables and messages. Thus, the concept of the class hierarchy is
maintained to depict the similarities among various classes.
The concept of encapsulation that is the data or information hiding is also supported by an object -
oriented data model. And this data model also provides the facility of abstract data types apart from
the built-in data types like char, int, float. ADT’s are the user-defined data types that hold the values
within them and can also have methods attached to them.
Features of ODBMS:
Object-oriented data model: ODBMS uses an object-oriented data model to store and
manage data. This allows developers to work with data in a more natural way, as objects are
similar to the objects in the programming language they are using.
Complex data types: ODBMS supports complex data types such as arrays, lists, sets, and
graphs, allowing developers to store and manage complex data structures in the database.
Automatic schema management: ODBMS automatically manages the schema of the
database, as the schema is defined by the classes and objects in the application code. This
eliminates the need for a separate schema definition language and simplifies the development
process.
High performance: ODBMS can provide high performance, especially for applications that
require complex data access patterns, as objects can be retrieved with a single query.
Data integrity: ODBMS provides strong data integrity, as the relationships between objects
are maintained by the database. This ensures that data remains consistent and correct, even in
complex applications.
Concurrency control: ODBMS provides concurrency control mechanisms that ensure that
multiple users can access and modify the same data without conflicts.
Scalability: ODBMS can scale horizontally by adding more servers to the database cluster,
allowing it to handle large volumes of data.
Support for transactions: ODBMS supports transactions, which ensure that multiple
operations on the database are atomic and consistent.
Advantages:
Supports Complex Data Structures: ODBMS is designed to handle complex data
structures, such as inheritance, polymorphism, and encapsulation. This makes it easier to
work with complex data models in an object-oriented programming environment.
Improved Performance: ODBMS provides improved performance compared to traditional
relational databases for complex data models. ODBMS can reduce the amount of mapping
and translation required between the programming language and the database, which can
improve performance.
Reduced Development Time: ODBMS can reduce development time since it eliminates the
need to map objects to tables and allows developers to work directly with objects in the
database.
Supports Rich Data Types: ODBMS supports rich data types, such as audio, video, images,
and spatial data, which can be challenging to store and retrieve in traditional relational
databases.
Scalability: ODBMS can scale horizontally and vertically, which means it can handle larger
volumes of data and can support more users.
Disadvantages:
Limited Adoption: ODBMS is not as widely adopted as traditional relational databases,
which means it may be more challenging to find developers with experience working with
ODBMS.
Lack of Standardization: ODBMS lacks standardization, which means that different
vendors may implement different features and functionality.
Cost: ODBMS can be more expensive than traditional relational databases since it requires
specialized software and hardware.
Integration with Other Systems: ODBMS can be challenging to integrate with other
systems, such as business intelligence tools and reporting software.
Scalability Challenges: ODBMS may face scalability challenges due to the complexity of
the data models it supports, which can make it challenging to partition data across multiple
nodes.
Many vector drawing applications, for example, have an OOUI – the objects being lines,
circles and canvases.
The user may explicitly select an object, alter its properties (such as size or colour), or invoke
other actions upon it (such as to move, copy, or re-align it).
Jakob Nielsen defines the OOUI in contrast to function-oriented interfaces: "Object-oriented
interfaces are sometimes described as turning the application inside-out as compared to
function-oriented interfaces.
The main focus of the interaction changes to become the users' data and other information
objects that are typically represented graphically on the screen as icons or in windows
Dave Collins defines an OOUI as demonstrating three characteristics:
Users perceive and act on objects.
Users can classify objects based on how they behave
Jef Raskin suggests that the most important characteristic of an OOUI is that it adopts a 'noun-
verb', rather than a 'verb-noun' style of interaction, and that this has several advantages in terms
of usability.
Methodology
We used the OMT methodology because it has the facility to manage objects in the
design step.
These objects can be used in programming and databases in the object oriented
approach.
Our goal is to handle geographic objects in three levels: design, programming and
databases.
At the same time, we keep the advantages offered by the relational model.
Data Model
Two approaches were considered to implement our ideas:
• object oriented database systems
• object/relational database systems
a)Object oriented model
This approach was inspired from the object oriented programming languages.
The principal object oriented languages are C++ and Java.
The object oriented paradigm includes the abstract data type concept.
The abstract data type declarations are public or private.
In an object oriented language, the types are implemented by classes.
The object operations can also be public or private.
An object is a black box, that is built and modified independently of other objects.
As the object oriented paradigm is developed new approaches are proposed to
implement the concepts related to the object paradigm.
Each approach can manage several object concepts in a different way.
b) Object/Relational model
The more direct way to implement objects in a database and to keep the DBMS
advantages is the Object/Relational model.
A standard for a multimedia data manager is developed in the context of the SQL
standard.
To manage geographic data in an object database, the data types are first created.
A hierarchy is used to represent from the basic data types to the more complex.
All the data types are then implemented by classes in an object oriented language
programming.
In the context of an object database the data that reference the data types is stored in
tables, but the structure of the data is represented by the types.
Geographic objects
The basic geographic objects that we use are:
points
lines
Polylines
polygons
Every kind of object is modeled by an abstract data type.
We use the vectorial geometry to represent the geographic objects.
This kind of modeling matches the representation used by the user interface.
The geometry used in the interface and in the database is based on standard
geographic data.
The database and the interface shall be used in the context of an interoperability GIS.
OOGIS model
The principal contribution of our work is the implementation of persistence for
geographic objects.
The following figure shows the class hierarchy.
It shows in the first level the View class.
Each View class is formed by several layers.
In the second level we then represent the Layer class.
Each Layer class can be modeled by one and only one data type.
A brief description of the geographic objects is the following:
Prototype
Our model was tested by using the Java object oriented language program and IUS
DBMS on Solaris.
Our application has the following modules:
• the operations manager
• the database server
• the interface manager
• the modeling manager
Our prototype was tested with data from the Universidad de las Americas, campus.
The prototype architecture is shown in the following figure.
An example of the creation of tables and the data insertion is as follows:
Object-Oriented Analysis (OOA) is the first technical activity performed as part of object-
oriented software engineering. OOA introduces new concepts to investigate a problem. It is
based on a set of basic principles, which are as follows:
Behavior is represented:
OOA also helps you understand what your game characters will do. If a character
jumps when you press a button, OOA helps describe that action. It’s like writing
down a script for each character.
Data, functional, and behavioral models are divided to uncover greater detail:
OOA is smart about breaking things into different parts. It splits the job into three
categories: things your game knows (like scores), things your game does (like
jumping), and how things in your game behave (like characters moving around). This
makes it easier to understand.
It allows effective management of software All the interfaces between the objects
complexity by the virtue of modularity. cannot be represented in a single diagram.
1. The Subsystem Layer: It represents the subsystem that enables software to achieve user
requirements and implement technical frameworks that meet user needs.
2. The Class and Object Layer: It represents the class hierarchies that enable the system to
develop using generalization and specialization. This layer also represents each object.
3. The Message Layer: This layer deals with how objects interact with each other. It includes
messages sent between objects, method calls, and the flow of control within the system.
4. The Responsibilities Layer: It focuses on the responsibilities of individual objects. This
includes defining the behaviour of each class, specifying what each object is responsible for, and
how it responds to messages.
Scalability: OOAD can help developers design software systems that are scalable and can
handle changes in user demand and business requirements over time.
Maintainability: OOAD emphasizes modular design and can help developers create software
systems that are easier to maintain and update over time.
Flexibility: OOAD can help developers design software systems that are flexible and can adapt
to changing business requirements over time.
Improved software quality: OOAD emphasizes the use of encapsulation, inheritance, and
polymorphism, which can lead to software systems that are more reliable, secure, and efficient.
1. Financial Systems:
Banking Software
2. Healthcare Systems:
Electronic Health Record (EHR) Systems
3. Aerospace and Defense:
Flight Control Systems
4. Telecommunications:
Telecom Billing Systems:
5. E-commerce:
Online Shopping Platforms
.
Some important points to know about OOP:
Advantages of OOPs –
Disadvantages of OOPs –