Pillars of OOP Flashcards
Object-oriented programming is based on four pillars, concepts that
differentiate it from other programming paradigms(system of concepts)
4 pillars
Abstraction
Encapsulation
Inheritance
Polymorphism
Abstraction
model of a real-world object or phenomenon,
limited to a specific context, which represents all details relevant to this context with high accuracy and omits all the rest.
each object has
an interface —
a public part of an object, open to interactions
with other objects
Encapsulation is
the ability of an object to hide parts of its
state and behaviors from other objects, exposing only a limit-
ed interface to the rest of the program.
To encapsulate something means to make it
private and thus
accessible only from within of the methods of its own class.
There’s a little bit less restrictive than private mode called
protected that
makes a member of a class available to subclasses as well.
the interface mechanism (usually declared with the
interface or protocol keyword) lets you
define contracts of
interaction between objects.
Inheritance is
the ability to build new classes on top of exist-
ing ones.
he main benefit of inheritance is
code reuse.
The consequence(result) of using inheritance is that
subclasses have
the same interface as their parent class. You can’t hide a
method in a subclass if it was declared in the superclass. You
must also implement all abstract methods, even if they don’t
make sense for your subclass.
In most programming languages a subclass can extend only
one superclass.
any class can implement
several
interfaces at the same time
if a superclass implements an interface,
all of its subclasses
must also implement it.
Polymorphism is
the ability of a program to detect the real class of an object and call its implementation even when its real
type is unknown in the current context.