oop Flashcards

1
Q

What is DRY?

A

Don’t repeat yourself. It is part of the OOD principles and encourages code reuse.

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

What is the dot ‘.’ when working with classes

A

The access modifier which allows us to access attributes and call methods on an aobject

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

How do you check if a specific object is of a specific type?

A

isinstance(object, type)

print(isinstance(baby, Person)) # Should print True
print(isinstance(baby, object)) # Should print True

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

Is Python an Object Oriented Language

A

Python is object oriented under the hood but it’s not an object oriented first language

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

What is duck-typing also known as

A

Polymorphism

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

What is polymorphism/duck-typing

A

Where the interface to the object determines how it is to be used

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

What is the design principle that encapsulates OOD design principles

A

SOLID

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

What are the SOLID stages?

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

What is the Open-Closed Principle?

A

A class should have only one reason to change
A reason = an actor
A module, a class, or a method should be responsible for a SINGLE FUNCTIONALITY of a software system

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

what is an actor?

A

pysical actors (people), or an abstarct actor (a component of your software)

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

How to spot SRP violations?

A

Is the class serving more than one actor?
Do the functionalities of the class serve the same actor??
Is the class responsible for many functionalities?

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