0% found this document useful (0 votes)
65 views15 pages

Object Oriented Programing

The document presents a detailed overview of Abstract Data Types (ADT) and Object-Oriented Programming (OOP), explaining their definitions, key features, and implementations. It covers concepts such as data types, encapsulation, polymorphism, and the importance of ADT specifications. The presentation emphasizes the benefits of using ADTs and OOP principles in software development for improved modularity and maintainability.

Uploaded by

rijusaha2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views15 pages

Object Oriented Programing

The document presents a detailed overview of Abstract Data Types (ADT) and Object-Oriented Programming (OOP), explaining their definitions, key features, and implementations. It covers concepts such as data types, encapsulation, polymorphism, and the importance of ADT specifications. The presentation emphasizes the benefits of using ADTs and OOP principles in software development for improved modularity and maintainability.

Uploaded by

rijusaha2003
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

MURSHIDABAD COLLEGE OF ENGINEERING AND TECHONOLOGY

Presentation on.
Abstract DataTypes & Features of Object Oriented Programming

 NAME –SAGNIK SAHA


❑UNIVERSITY ROLL –10600123029
❑REGISTRATION NO –231060110049(2023-2024)
❑SEMESTER – 5TH ❑YEAR – 3 rd
❑PAPER NAME – Object Oriented Programming
❑PAPER CODE –PCC-CS503
❑DEPARTMENT –COMPUTER SCIENCE AND ENGINEERING
TOPIC :
Abstract Data Types &
Object-Oriented
Programming
What is data types ?
 In Object-Oriented Programming (OOPs), a data type defines the kind of data that a variable, object
property, or method parameter can hold, along with the operations that can be performed on it.
 It tells the compiler/interpreter:
 What kind of values are allowed (e.g., numbers, text, true/false).
 How much memory is needed.
 What operations are legal (e.g., addition for numbers, concatenation for strings).
 In OOP, data types can be classified into:
1. Primitive Data Types
These are the basic building blocks provided by the language.
Examples (in Java, C++, etc.):
int → integers (e.g., 42)
float / double → decimal numbers
char → single character (e.g., 'A')
boolean → true or false
2. Non-Primitive (Reference) Data Types
These store references to objects in memory, not the actual value.
Introduction to Abstract Data Types (ADT)

Definition:
An Abstract Data Type (ADT) is a mathematical model for data types, where the
data type is defined by its behavior (operations) rather than its implementation.
Key Points:
Focuses on what an operation does, not how it is done.
Acts like a “black box” — users interact via operations without knowing the internal structure.
Encapsulates data and permitted operations together.
Examples of ADTs:
Stack → Operations: push(), pop(), peek().
Queue → Operations: enqueue(), dequeue().
List → Operations: insert, delete, search, traverse.
Benefits:
Hides complexity from the user.
Allows multiple possible implementations without changing the interface.
ADT Specification :
Components of an ADT Specification:

Name of the ADT – Identifies the abstract type (e.g., Stack, Queue, Text).
Data Types Stored – Specifies the kind of data elements (e.g., integers, characters).
Operations – For each operation:
Signature: Name, parameters, and return type.
Preconditions: Conditions that must be true before the operation is performed.
Post conditions: Expected state/result after the operation is executed.
Behavioral Description – Explains the logical effect of each operation.

Example (Stack ADT):


Signature: push(element: int)
Precondition: Stack is not full.
Post condition: Element is added to the top of the stack.
Why Specification is Important:
Provides a clear interface for developers.
Allows different implementations to be swapped without affecting the program using the ADT.
How to Implement an ADT
Steps to Implement an ADT:
1 .Choose a Concrete Representation
Select an appropriate data structure to store the ADT’s data.
Example: Stack → Array or Linked List.
2. Define the Concrete State Space
Determine all possible valid internal states of the implementation.
This forms the “physical” form of the ADT in memory.
3. Establish Concrete Invariants
Set rules that must always hold true in any valid state.
Example: For a queue, 0 ≤ front ≤ rear ≤ max_size.
4. Create the Abstraction Function
Map the internal representation (concrete state) to the logical view (abstract state).
Implement Operations
Code each operation from the specification.
Ensure preconditions and postconditions are respected.
Example (Queue ADT):
Specification: enqueue(element) → adds item to the rear.
Implement Concrete State Space
Definition: Purpose:
The Concrete State Space of an ADT is Serves as the foundation for
the set of all possible internal implementing operations.
configurations of the chosen data Helps ensure that each possible state
representation. can be mapped to a valid abstract state.
It describes how the ADT’s data is Characteristics:
physically stored in memory. Dependent on the data structure
chosen for implementation.

Example 1 – Stack ADT (Array Implementation):


State variables:
elements[] → Array storing the stack items.
top → Index of the top element.
Concrete state space: All combinations of elements[] and top where 0 ≤ top ≤ max_size.
Implement Concrete Invariant
Definition: Purpose:
A Concrete Invariant is a logical Maintains data consistency and integrity.
condition that must always be true for Ensures that operations never produce or leave
every valid state of the ADT’s concrete the ADT in an invalid state.
representation. Key Properties:
It filters out invalid states from the Checked before and after operations to validate
concrete state space. correctness.
Derived from the abstract rules of the ADT.

Example 1 – Stack (Array Implementation):


State variables: elements[], top.
Invariant: 0 ≤ top ≤ max_size.
Ensures the top index is always within bounds.
Implement Abstraction Function
Definition: How It Works:
An Abstraction Function maps a concrete Take the current internal (concrete)
state (physical data representation) to the variables.
corresponding abstract state (logical model Apply transformation rules.
defined in the specification). Produce the logical/abstract
It acts as a bridge between the representation visible to the user.
implementation and the ADT’s conceptual
definition.

Example 1 – Stack (Array Implementation):


Concrete state: elements[] = [A, B, C, _, _], top = 3
Abstraction function: Return abstract stack (A, B, C)
Implementing Operations
Goal:
To create functions/methods that perform the ADT’s specified operations while
maintaining the concrete invariant and respecting the abstraction function.

Example 1 – Stack ADT (Array Implementation): Important:


push(x) → Every operation must
Check: top < max_size leave the ADT in a valid
Update: elements[top] = x; top++ state.
pop() → Incorrect
Check: top > 0 implementation can break
Update: top-- and return elements[top]. the abstraction and cause
unpredictable behavior.
Introduction to Object-Oriented
Programming (OOP)
Definition:
Object-Oriented Programming (OOP) is a programming paradigm that organizes
software around objects, which are instances of classes containing both data (attributes)
and methods (functions).
Why OOP?
Encourages modularity — code is divided into smaller, reusable parts.
Improves maintainability — changes in one part have minimal effect on others.
Promotes abstraction — hide internal details, show only necessary functionality.

Key Features (Covered Here):


Encapsulation – Bundling data & methods together, restricting direct access to data.
Object Identity – Each object is unique, even if it holds the same data as another.

Examples in Real Life:


A Car object → attributes: color, speed; methods: accelerate(), brake().
A Bank Account object → attributes: balance, accountNumber; methods: deposit(), withdraw().
Encapsulation :
Definition:
Encapsulation is the practice of bundling data and the methods that operate on that
data within a single unit (class), while restricting direct access to some components.
Purpose:
Protects the internal state of an object.
Allows changes to the implementation without affecting external code.
Enforces controlled interaction with the object through defined methods.
How It Works:
Private Data Members → Accessible only within the class.
Public Methods (Getters/Setters) → Provide controlled access to data.
Benefits:
Data Hiding – Prevents unauthorized or unintended modification.
Security – Maintains object integrity.
Maintainability – Internal changes don’t break other parts of the program.
Polymorphism :
Definition:
Polymorphism means “many forms”.
It allows different objects to respond to the same operation in different ways, depending
on their specific type or context.
Types of Polymorphism:
Compile-time (Static) Polymorphism
Achieved through method overloading or operator overloading.
Decided at compile time.
Example: Multiple print() methods with different parameter types.
Runtime (Dynamic) Polymorphism – Possible without inheritance via interfaces or duck typing
Achieved through method overriding (if using interfaces) or dynamic typing (Python-style).
Decided at runtime.
Example: Different classes implementing the same interface but with different behaviors.
Conclusion ::
Abstract Data Types (ADT):
Define what operations are available, not how they are implemented.
Built using:
Concrete State Space → Possible physical states.
Concrete Invariants → Rules that ensure validity.
Abstraction Function → Maps physical state to logical view.
Implementation must maintain invariants and follow the specification.
Object-Oriented Programming (OOP):
Organizes software around objects combining data & behavior.
Key features (without inheritance):
Encapsulation – Protects and controls data access.
Object Identity – Every object is unique.
Polymorphism – Same operation, different behaviors.
THANK YOU

You might also like