Clean code applied to JavaScript - Part III. Functions

Click for: original source

Carlos Caballero published this story about fundamental tips and advice to generate clean code focusing on the element that allows us to reuse our code: the functions.

Some tips to generate good code applied specifically to the variables:

  • Use default arguments instead of short circuiting or conditionals
  • Function arguments (2 or fewer ideally)
  • Avoid side effects – Global Variables
  • Avoid side effects – Objects Mutables
  • Functions should do one thing
  • Favor functional programming over imperative programming
  • Use method chaining

The design of functions applying clean code is essential because the functions are the basic element to decouple the code. Good read!

[Read More]

Tags javascript programming functional-programming