Slides Sheshnath Clean Code Seminar Project
Slides Sheshnath Clean Code Seminar Project
Any fool can write code that a computer can understand. Good programmers write
code that humans can understand.
Why should you care to keep your code clean?
● Well Structured Code is easy to
understand.
● Better use of one’s time - for
author and fellow developers.
● Saves Costs by Saving time.
Easier Onboarding of new
members.
● Easier Debugging and efficient
maintenance.
Rules that will help you always keep your code clean
● Good example:
var elapsedTimeInDays;
var daysSinceCreation;
var daysSinceModification;
getName() , sendEmail() …
Boolean name should answer y/n
isGoldClient() , areHostsvalid()
2. KISS(Keep it simple,Stupid)
● “Make everything as simple as possible but not
simpler”
- Albert Einstein
● Keep Code as Simple as possible.
● Engineers like to complicate things.
Unnecessary complexity should be avoided.
● It makes it easy to understand and maintain.
● How to keep code simple?
● Break down the problem into small steps and
write minimal code to implement them.
● Also, always ask yourself and the reviewer -
can this be written in simpler way?
3. Clean code requires clear information
Ifyou use words that are too ambiguous, you can end up with messy code.
Always make sure that your code doesn’t contain misinformation.
● Bad example:
● Good example:
const currentDate=moment().format("YYYY/MM/DD");
Int getInvoiceableCreaditLimit()
5. Give each function a single purpose
Every function or class should
represent one concept or perform
one action only. openDoor should not
also call putClothesOn. Once it does
two things, it becomes more difficult
to test
Example →
6 . Polish your comments
The common trap, especially for beginners, is
overexplaining how your code works in comments.
Unfortunately, too much information in the comments can
turn your code into chaos.
Here are some rules that will help you write your
comments like a professional:
For example-
‘Paris’ is Street .