DEV Community

Discussion on: Function vs Object

Collapse
 
vlasales profile image
Vlastimil Pospichal

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

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

Collapse
 
daveparr profile image
Dave Parr

From Nidavellir import mjölnir as stormbreaker

Stormbreaker.smash()

Collapse
 
olvnikon profile image
Vladimir

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));