programming paradigms :( Flashcards

(15 cards)

1
Q

what is OOP

A

models software as a collection of objects that encapsulate data and behaviour. it promotes modularity, reusability and scalability

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

what is encapsulation

A

the bundling of data with the methods that operate on that data, restricting direct access to some of an object’s components (eg private attributes)

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

what is polymorphism

A

the ability for different classes to respond to the same method call in different ways

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

what is message passing

A

objects communicate with each other by sending and receiving messages (method calls)

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

what is the logic paradigm

A

a declarative paradigm, focusing on defining facts and rules about a problem domain and letting the system infer solutions using logical deduction

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

what are facts and rules

A

fact: a basic assertion about some world element
animal(dog)

rule: a logical statement/implication that defines relationships
mammal(X) :- animal(X), warm_blooded(X)

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

what is backtracking (logic paradigm)

A

the system searches through possibilities to find all matches that satisfy a query

(query: questions posed to the system that it answers based on facts and rules)

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

What does it mean to display the solution and rules in logic programming

A

Outputting which rules were used to infer a solution, aiding transparency and debugging

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

what is the imperative paradigm

A

based on explicit sequences of commands that change a program’s state. it is the traditional and most widely used approach

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

what are key concepts in the imperative paradigm

A
  • control structures (if, else, for, while - control flow of execution)
  • variables and assignment (used to store and update data)
  • expressions (combinations of variables, values and operators that evaluate to a result)
  • subroutines (blocks of reusable code that perform specific tasks)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

what is the functional paradigm

A

approach that treats computation as the evaluation of mathematical functions, without changing state or mutable data

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

what is recursion and how is it used in functional programming

A

recursion is a process where a function calls itself to solve smaller instances of a problem. it replaces loops, and is fundamental to functional languages

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

what is a pure function

A

returns the same output for the same input, and doesn’t cause any side effects or modify external state

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

what does it mean for functions to be first class objects?

A

functions can be stored in variables, passed as arguments and returned from other functions like any other data

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

what is abstraction and encapsulation in functional programming

A

abstraction hides the implementation details of a function and allows users to use it without knowing its internal workings.

encapsulation is achieved by limiting scope and using pure functions, as state and data are hidden within functions, which reduces unintended side effects

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