Object Oriented Programming Flashcards
What is encapsulation?
Two main points:
(1) The idea of data hiding or restricting access to data. You want to be able to keep classes loosely coupled, and only expose data that you want to share with other classes in the system.
(2) To put operations that operate on some data and the data in the same place (i.e., the same class). This is also known as cohesion.
What is polymorphism?
When classes have different functionality while sharing the same interface. Example: a blue ray player that also plays DVDs. Talk about classes and inheritance.
What is composition?
Simply, when an object is made up of other types. One object owns the other objects that it is made of. You should mention why it’s preferred over inheritance or how it’s different from aggregation.
What is a design pattern?
A solution to a common software problem that generally occurs in different situations. It’s a template, rather than a specific implementation. They originated in architecture. Give a common vocabulary that can communicate a large amount of information with a few words.
What is a singleton pattern?
The heart of this pattern is the idea of restricting the instantiation of a class to a single instance — there can be only one. Talk about how they can often be overused, and can be considered an anti-pattern when used too frequently.