Basic Principles Flashcards
What are the 4 pillars of OOP
A PIE
1) Abstraction
2) Polymorphism
3) Inheritance
4) Encapsulation
Describe abstraction
= is an extension of Encapsulation
= you can hide the details of how data is stored and used within a class.
- Only exposes the Properties and Methods
Describe polymorphism
= allows objects of different classes to be treated as objects of a common superclass.
It enables methods to be invoked on objects without knowing their specific types, leading to more flexible and reusable code.
= uses inheritance and interfaces?
Describe Inheritance
= allows a class (subclass) to inherit attributes and methods from another class (superclass).
- It promotes code reuse and facilitates the creation of hierarchies of related classes.
- allows us to create more specific versions of an existing class
Describe Encapsulation
= idea that you package everything an object is and can do into a class
= helps hide the internal implementation details of an object and provides access through well-defined interfaces.
What are the SOLID principles?
S = Single-responsibility
O = Open-closed
L = Liskov Substitution
I = Interface Segregation
D = Dependency Inversion