Object Oriented Flashcards

1
Q

What is Object Oriented Programming?

A

Object Oriented Programming is a programming paradigm based on objects that contain data and procedures.

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

What are the Pillars of OOP?

A

Encapsulation
Inheritance
Polymorphism
Bonus - Abstraction

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

What is Encapsulation?

A

Encapsulation packages data and procedures up into a single unit. Removes access to all the information and only certain bits are exposed

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

What is Inheritance?

A

Classes can share and reuse code from other classes. A child class gains functionality from the parent class.

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

What is Polymorphism?

A

Using the object differently depending on how it is being used. Change the behaviour of implementation of a method based on the type using it or the parameters being used.

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

What is abstraction?

A

Abstraction (Bonus 4th Pillar) - Only expose what is necessary, keep the details hidden when possible. For example protect the internal state of an object by having a private field but a public property to set it.

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

Name the Solid Principles

A
Single Responsibility Principle
Open/Close Principle
Liscov’s Substitution Principle
Interface Segregation Principle
Dependency Inversion Principle
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Explain Single Responsibility Principle

A

Single Responsibility Principle - “A software module should have one and only one reason to change”. A piece of code should only have one purpose and it should not try to do multiple things.

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

Explain Open/Close Principle

A

Open/Close Principle - “Code should be open for extension and closed to modification”. You should be able to change or add new behaviour without changing the source code. (E.g. adding parameters to a method so it can be reused or overriding/overloading methods)

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

Explain Liscov’s Substitution Principle

A

Liscov’s Substitution Principle - “Subtypes should be substitional for their base types”. Use the phrase “is substitutional for” (E.g. A cat (sub class) is substitutional for an animal (base class) as it will still fulfil the requirements of the base class).

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

Explain Interface Segregation Principle

A

Interface Segregation Principle - “Clients should not be forced to depend on methods they do not use”. Code should not have to inherit from an interface that contains methods that are not required so will not be properly implemented.

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

Explain Dependency Inversion Principle

A

Dependency Inversion Principle - “High level modulus should not have to depend on low level modules, both should depend on abstractions”. “Abstraction should not depend on details. Details should depend on abstractions” Code should be loosely coupled and classes should depend on abstract classes or interfaces to fulfil this principle.

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

What is Functional Programming?

A

Functional Programming is a programming paradigm based on the concept of mathematical functions and building functions for immutable variables.

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