OOP vs FP
OOP:
Organizing a code into a unit.
Grouping things into a box, known as states and action performed is methods.
Objects are the first class citizens.
Principles are Abstraction, Encapsulation, Inheritance and Polymorphism.
Few operations on common data.
State can be modified (mutable).
Has side effects.
Imperative.
FP:
Avoiding side effects and writing pure functions.
Combination of data is functions. The result will be based on the input data without any side effects and is immutable.
Functions are first class citizens.
It all around the pure function and compose.
Many operations on fixed data.
State is immutable.
Pure and no side effects.
Declarative.
Last updated