In computer science, imperative programming is a programming paradigm that uses statements that change a program's state.
Imperative programming focuses on describing how a program operates.
is a programming paradigm [...] that expresses the logic of a computation without describing its control flow.
Many languages that apply this style attempt to minimize or eliminate side effects by describing what the program must accomplish in terms of the problem domain, rather than describe how to accomplish it as a sequence of the programming language primitives (the how being left up to the language's implementation). This is in contrast with imperative programming, which implements algorithms in explicit steps.
don't use unrestrained GOTO (Robert C. Martin)
aimed at improving the clarity, quality, and development time of a computer program by making extensive use of subroutines, block structures, for and while loops—in contrast to using simple tests and jumps such as the go to statement which could lead to "spaghetti code" causing difficulty to both follow and maintain.
Functional programming is a style of programming which models computations as the evaluation of expressions. This article is meant to describe it briefly; however, the best way to understand functional programming is to learn the basics of one of the functional programming languages
Very quick TLDR : avoids shared state & mutable data, functions always returns a value & a function with given args will always returns the same value.
don't use assignment (Robert C. Martin)
No assignment means var are immutables.
a style of building the structure and elements of computer programs—that treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data. It is a declarative programming paradigm, which means programming is done with expressions or declarations instead of statements.
N.B. : An expression is not a statement but a valid unit of code that resolves to a value. Not all statements resolve to a value.
don't use pointers to functions (Robert C. Martin) (He is talking about pointers in C++)
based on the concept of "objects", which may contain data, in the form of fields, often known as attributes; and code, in the form of procedures, often known as methods. A feature of objects is that an object's procedures can access and often modify the data fields of the object with which they are associated (objects have a notion of "this" or "self"). In OOP, computer programs are designed by making them out of objects that interact with one another.
TLDR : imperative versus functional === control flow versus data flow
For example, in imperative programming variables and loops are common when handling state, while in functional programming the state is handled via parameter passing, which avoids side-effects and assignments.
TDLR : If logic evolves more then the model : choose FP and if model evolves more then the logic : choose OOP
OOP is good when you have a fixed set of operations on things. Your code evolves, you primarily add new things. Adding new classes which implement existing methods (operations).
FP is good when you have a fixed set of things Your code evolves, you primarily add new operations (functions) on existing things (data types).
When evolution goes the wrong way, you have problems (The Expression Problem : Philip Wadler 19981112):
Adding a new operation to an OOP program may require editing many class definitions to add a new method.
Adding a new kind of thing to a FP program may require editing many function definitions to add a new case.
Functional languages excel at manipulating symbolic data in tree form.