How to Write Clean Code?

Basic Hygiene

  • Leave the place cleaner than you got it.

Naming Convention

  • Do one thing in a function. Name should reflect the action. Function name is a verb.
  • Declare literals ([a-z]+, [0-9]+) as constants.


  • The function should not exceed twenty lines.
  • Each if, else, while statement can become a function.
  • The function can have one or two levels of indentation.
  • A function must do only one thing. The one thing is discovered when function can’t be reduced further. The reduced name is similar to the function’s current name.

This post is updated until the book “Clean Code” completes!


Written with StackEdit.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: