OOP Design Guidelines Flashcards

1
Q

What is OOP?

A

Object Oriented Programming.

It has a number of principles and guidelines to follow to get a good design.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the OOP guidelines regarding Data Access?

A

Encapsulate objects and use getters and setters.
Classes should not expose how they work internally.
Minimize the accessibility of classes (private).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you enforce encapsulation?

A

Set classes to private but use public getters and setters

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the DRY principle?

A

Don’t repeat yourself.

Basically if you are writing duplicate code you might want to create a class with the methods and extend them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is the Principle of least knowledge (Law of Demeter)?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is Inheritance?

A

It’s when a class inherits from a parent class. an “is a” relationship.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Why does inheritance break the encapsulation rules?

A

because it opens up a class to another.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the Single responsibility principle (class?

A

a class should only do one thing and do it well rather than having focus on many things.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly