OOP vs FP

OOP:

  1. Organizing a code into a unit.

  2. Grouping things into a box, known as states and action performed is methods.

  3. Objects are the first class citizens.

  4. Principles are Abstraction, Encapsulation, Inheritance and Polymorphism.

  5. Few operations on common data.

  6. State can be modified (mutable).

  7. Has side effects.

  8. Imperative.

FP:

  1. Avoiding side effects and writing pure functions.

  2. Combination of data is functions. The result will be based on the input data without any side effects and is immutable.

  3. Functions are first class citizens.

  4. It all around the pure function and compose.

  5. Many operations on fixed data.

  6. State is immutable.

  7. Pure and no side effects.

  8. Declarative.

Last updated