Well we all know how to write clean code but we dont follow it. We
dont follow it because we are lazy. All human beings are lazy until
they reach a point where they dont understand their own code after a
weekend So clean code is just a habit that a developer started and is
continuously follows it. Don{"'"}t think about the clean code at first
when you try to solve a problem. Just solve the problem first. I want
to focus this blog on the funcitons to write clean code. So here is my
take on clean code with functions.
Part 1: Functions
There are different rules that we should follow for functions. The
rules are as follows:
Function that returns void should always have side effects.
Function that returns something should not have side effects.
Function name should always be a verb. It should always tell
what the function does.
Define types if you are using typescript else use javascript
comment feature for function.
In many arguments use objects instead of many arguments.