what is OOP
models software as a collection of objects that encapsulate data and behaviour. it promotes modularity, reusability and scalability
what is encapsulation
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)
what is polymorphism
the ability for different classes to respond to the same method call in different ways
what is message passing
objects communicate with each other by sending and receiving messages (method calls)
what is the logic paradigm
a declarative paradigm, focusing on defining facts and rules about a problem domain and letting the system infer solutions using logical deduction
what are facts and rules
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)
what is backtracking (logic paradigm)
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)
What does it mean to display the solution and rules in logic programming
Outputting which rules were used to infer a solution, aiding transparency and debugging
what is the imperative paradigm
based on explicit sequences of commands that change a program’s state. it is the traditional and most widely used approach
what are key concepts in the imperative paradigm
what is the functional paradigm
approach that treats computation as the evaluation of mathematical functions, without changing state or mutable data
what is recursion and how is it used in functional programming
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
what is a pure function
returns the same output for the same input, and doesn’t cause any side effects or modify external state
what does it mean for functions to be first class objects?
functions can be stored in variables, passed as arguments and returned from other functions like any other data
what is abstraction and encapsulation in functional programming
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