Anish Logo
  • enflagEnglish (US)
  • npflagनेपाली(NP)
  • Home
  • Tools
  • Pricing
  • Blogs
Clean code

Clean Code with functions

Anish Shrestha
February 22, 2025
1 min
Clean Code with functions
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:
  1. Function that returns void should always have side effects.
  2. Function that returns something should not have side effects.
  3. Function name should always be a verb. It should always tell what the function does.
  4. Define types if you are using typescript else use javascript comment feature for function.
  5. In many arguments use objects instead of many arguments.
Clean code with functions
Functional approach