Object Oriented Programming (OOP) - CS304 Power Point Slides Lecture 02
Object Oriented Programming (OOP) - CS304 Power Point Slides Lecture 02
(OOP)
Lecture No. 2
Information Hiding
• 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
• Low Complexity