Telechargé par cfode92i

abstraction vs encapsulation

publicité
Encapsulation
Abstraction
by Steven Giesel
Encapsultion
Take Away
Hides the internal workings of an objec
We want to “hide” and protect the data in a single uni
Focusing on how it is don
Less coupling, better testability
Abstraction
Take Away
Hides unncessary detailt but showing essential informatio
Focuses on the external representatio
Focusing on what should be don
Can be achieved via interfaces or (abstract) classes
Real world example
Abstraction
For braking, there is only
an interface provided for
you (namely the break
pedal
The user does not have to
care how it works, but has
to have the opportunity
from the outisde world
Encapsulation
An engine consists out of
hundreds of smaller parts,
but there are encapuslated
under the name “engine”
Téléchargement