This document discusses information hiding, which means showing only necessary details to others and hiding unnecessary details. It provides examples like how a person's personal information is hidden in their brain and a phone SIM card hides phone numbers. The advantages of information hiding are that it simplifies models and acts as a barrier against changes. Encapsulation and abstraction are used for information hiding. Encapsulation bundles data and operations within an object, while abstraction focuses on relevant details from an object's perspective.
3. By Information Hiding we mean “Showing only
those details to the outside world which
are necessary for the outside world and hiding
all other details from the outside world.”
4. Real Life Examples of Information Hiding
• Sameen’s name and her personal information is
stored in her brain you can’t access this information
directly. For getting this information we need to ask
Sameen about it and it will be up to Sameen how
much details he would like to share with you.
• We have multimedia in our class, we saw the
working of multimedia that we use it to share our
ideas and teachers use it to deliver their lectures.
But we do not know about its internal functions.
5. • A phone SIM card may store several phone numbers
but we can’t read the numbers directly from the
SIM card rather phone-set reads this information for
us and if the owner of this phone has not allowed
others to see the numbers saved in this phone we
will not be able to see those phone numbers using
phone.
6.
7. Advantages of Information Hiding
• There are two major advantages of information hiding
which are as follows:
It simplifies our Object Oriented Model:
As we saw that our OO model had objects and their
interactions hiding details so it makes it easier to
understand our OO model.
It is a barrier against change propagation:
As implementation of functions is limited to our class
and we have given name of functions to user with
description of parameters so if we change
implementation of function it doesn’t affect the OO
model.
9. Encapsulation
• Encapsulation means “we have enclosed all the
characteristics of an object in the object itself”.
• Encapsulation is a mechanism of bundling the data,
and the functions that use them.
• Both the information structure and implementation
details of its operations are hidden from the outer
world.
11. • Ali stores his personal information and knows how
to translate it to the desired language.
• We don’t know
– How the data is stored
– How Ali translates this information
12. • We know the name of Ali and knows he can walk
and eat but we do not knows his personal
information.
13. • A Phone stores phone numbers in digital format and
knows how it works, we do not know internally
about phone.
• We don’t know
– How the data is stored.
– How it is converted to human-readable
characters.
16. Abstraction
• Real life objects have a lot of attributes and many
kind of behaviors but most of the time we are
interested in only that part of the objects that is
related to the problem we are currently going to
solve.
• We also say that “Capture only those details about
an object that are relevant to current perspective”
18. • If our data required organisms, mammals,
dangerous mammals then we have
19. • A cat can be viewed with different perspectives
20. Abstraction – Advantages
• It helps us understanding and solving a problem
using object oriented approach as it hides extra
irrelevant details of objects.
• Focusing on single perspective of an object provides
us freedom to change implementation for other
aspects of for an object later.