Object Oriented programming Flashcards

1
Q

What is OOP?

A

A paradigm that favours: objects over functions, data over logic. It is a logical procedure that takes in input data, processes it and returns as output

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

How does javascript interpret OOP?

A

Javascript is not by nature a class based language and classes in javascript are what we call syntactic sugar over the constructor pattern. We mimic OOP in javascript using classes.

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

Name the four pillars of object oriented programming

A

Abstraction, Inheritance, Polymorphism and Encapsulation

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

How do we mimic OOP in javascript?

A

using pseudo-classical inheritance (and others). this depends upon constructor function, the new keyword and the prototype.

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

What is spaghetti code?

A

When you create many functions which interlink and create interdependencies between all the functions = problematic.

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

What problem does Object Oriented Programming solve?

A

the issue of spaghetti code. It allows us to create and group related functions and methods into objects. The variables are called properties and the functions are methods. In both javascript and ruby we use classes to achieve this.

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

What is encapsulation?

A

highly related properties and methods are bundled on one unit. It describes the idea of bundling data and methods that work on that data within one unit. If you have an attribute that is not visible from the outside of an object, and bundle it with methods that provide read or write access to it, then you can hide specific information and control access to the internal state of the object.

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

What is abstraction?

A

Its main goal is to handle complexity by hiding unnecessary details from the user. That enables the user to implement more complex logic on top of the provided abstraction without understanding or even thinking about all the hidden complexity. eg of the coffee machine you don’t need to know how it works to make the coffee!

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

What is abstraction?

A

Its main goal is to handle complexity by hiding unnecessary details from the user. That enables the user to implement more complex logic on top of the provided abstraction without understanding or even thinking about all the hidden complexity. eg of the coffee machine you don’t need to know how it works to make the coffee!
eg private methods in Ruby. Allows for a simpler interface and reduces the impact of change (so you can change private methods without it impacting the outside world!)

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

What is inheritance?

A

Inheritance allows you to eliminate redundant code.

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

Polymorphism?

A

technique that allows you to get rid of long if/ else and switch statements. So polymorphism is the ability (in programming) to present the same interface for differing underlying forms (data types).

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

Benefits of OOP?

A

reduce complexity, isolate impacts of changes, eliminate redundant code, increase reusability.

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