DEV Community


Discussion on: A short introduction to Functional Composition

functional_js profile image
Functional Javascript • Edited

Good summary Martin.

Though method-chaining looks quite similar to a functional pipeline, it has a number of drawback.

  • For one, it's Object-oriented programming (a can of worms).
  • Another is if we use one built-in method, then we can't use any custom methods, and we certainly don't want to add custom methods to another's object.
  • FP allows us to separate the data from the operations. OOP commingles those, resulting in spaghettification as system size increases.
  • FP give us more opportunity to use Point-free programming (Tacit programming)

I could go on. :)

Another side-by-side example of the two approaches....

Method Chaining vs Functional Pipelining

Forem Open with the Forem app