Object-Oriented Programming (OOP) Lecture No. 2
Object-Oriented Programming (OOP) Lecture No. 2
(OOP)
Lecture No. 2
Information Hiding
► Simplifies
the model by hiding
implementation details
► We don’t know
How the data is stored
How Ali translates this information
Example – Encapsulation
►A Phone stores phone numbers in digital
format and knows how to convert it into
human-readable characters
► We don’t know
How the data is stored
How it is converted to human-readable
characters
Encapsulation – Advantages
► Low complexity
► Better understanding
Object has an Interface
► This includes
Data structures to hold object state
Functionality that provides required services
Example – Implementation of
Gear Box
► Data Structure
Mechanical structure of gear box
► Functionality
Mechanism to change gear
Example – Implementation of
Address Book in a Phone
► Data Structure
SIM card
► Functionality
Read/write circuitry
Separation of Interface &
Implementation
► Because
interface does not change with the
implementation
Example – Separation of
Interface & Implementation
► Low Complexity