loading...

re: Function vs Object VIEW POST

TOP OF THREAD FULL DISCUSSION
re: OOP has hammers, functional programming has the ability to smash things. Advocates of OOP, like having specific things to smash with. Advocates o...
 

OOP: mjölnir.smash()
// mjölnir is an object

FP: mjölnir.smash()
// mjölnir is a namespace

 

From Nidavellir import mjölnir as stormbreaker

Stormbreaker.smash()

 

In FP functions without arguments are code smell because most probable they contain side effects. So in FP it would be:
const mjölnirSmash = smash(mjölnir);
const newGround = mjölnirSmash(currentGround);

Or with ADT something like this:
const ground = Functor(/* some data */);
const newGround = ground.map(smash(mjölnir));

Code of Conduct Report abuse