oop Flashcards
What is DRY?
Don’t repeat yourself. It is part of the OOD principles and encourages code reuse.
What is the dot ‘.’ when working with classes
The access modifier which allows us to access attributes and call methods on an aobject
How do you check if a specific object is of a specific type?
isinstance(object, type)
print(isinstance(baby, Person)) # Should print True
print(isinstance(baby, object)) # Should print True
Is Python an Object Oriented Language
Python is object oriented under the hood but it’s not an object oriented first language
What is duck-typing also known as
Polymorphism
What is polymorphism/duck-typing
Where the interface to the object determines how it is to be used
What is the design principle that encapsulates OOD design principles
SOLID
What are the SOLID stages?
What is the Open-Closed Principle?
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
what is an actor?
pysical actors (people), or an abstarct actor (a component of your software)
How to spot SRP violations?
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?