OOP Design Guidelines Flashcards
What is OOP?
Object Oriented Programming.
It has a number of principles and guidelines to follow to get a good design.
What are the OOP guidelines regarding Data Access?
Encapsulate objects and use getters and setters.
Classes should not expose how they work internally.
Minimize the accessibility of classes (private).
How do you enforce encapsulation?
Set classes to private but use public getters and setters
What is the DRY principle?
Don’t repeat yourself.
Basically if you are writing duplicate code you might want to create a class with the methods and extend them.
What is the Principle of least knowledge (Law of Demeter)?
Classes should only collaborate with other classes where it is necessary. To keep the dependencies to a minimum which causes the class to be flexible.
What is Inheritance?
It’s when a class inherits from a parent class. an “is a” relationship.
Why does inheritance break the encapsulation rules?
because it opens up a class to another.
What is the Single responsibility principle (class?
a class should only do one thing and do it well rather than having focus on many things.