Beginner's guide for Functional Programming

This article share basic idea of functional programming for beiginner.

🐮 Philosophy

  • Design policy to minimize ‘side effects’
  • Thinking of functional programming is “To add some processing to data” like mathmatic function.
  • It is important not to handle state.

😸 Function

Function is a mechanism that “converts” from input to output.

function: input =(converter)=> output

🐰 Side effects

  • It is changing some data except input one.
  • It is not good to return different output when calling same function with same argument.

🚜 Step for converting functional programming

  • Devide data and behavior. Decompose behavior into some functions without side effects
  • Determine input / output of function so as not to depend on outside condition
  • Use recursion and iteration methods like map, reduce to eliminate side effects

🎃 Object-oriented programming vs Functional programming

Object-oriented programming

Functional programming

🐞 Merits

  • A cause and a result is easy to understand.
  • It is easy to write unit test.

🗻 Demerits

  • As a function type trick, it manipulates data indirectly by passing it to Runtime

🤔 References

🖥 Recommended VPS Service

VULTR provides high performance cloud compute environment for you. Vultr has 15 data-centers strategically placed around the globe, you can use a VPS with 512 MB memory for just $ 2.5 / month ($ 0.004 / hour). In addition, Vultr is up to 4 times faster than the competition, so please check it => Check Benchmark Results!!