
We spend more time reading our code than writing it. So doesn’t it make sense that our code is clean, precise and easy to read? In this session we discuss how to take a code written in a hurry and apply best practices to refactor and clean it up. We will take a messy piece of code and step by step clean it up.
Why Clean Code?
Why do we need clean code? Bad code works too! Don’t fix what is not broken.
Code following best practices
- Easy to understand by other developers : readable by developers other than the one who developed it.
- Easy to maintain : lower chances of accidentally introducing bugs
- Modified without fear of breaking anything : Lot of developers take great pride in making the code compact – trying to do multiple things on one line – which might be impressive, but makes the code much harder to read and understand
Where do we begin ?
Clean code always looks like it was written by someone who cares.
Clean Code rules
- Keep your methods short
- Don’t repeat yourself
- Methods should do just one thing
- Clear, intention revealing names
- Comment to clarify not explain
- Leave everything better than you found it.
Please check this post to learn about Salesforce Naming Conventions Best Practices.
Agreed upon software standards
- Naming conventions
- Indentation
- White space
- Curly Braces – Cuddled or not
Accountability
- Commit to keeping code clean as a team
- Hold Code reviews to enforce standards
- Let schedules allow time for clean code
Recording
Check below recording to learn more about how to write clean code in Salesforce with Example.
Date : WED, JUN 27, 2020 10:00 AM EST ( 7:30 PM IST ) Where : ApexHours YouTube Speaker : Bhavana Singh |
Articles:
- Salesforce Naming Conventions Best Practices
- Putting comments in code: the good, the bad, and the ugly.
- Ottinger’s rules for variables and class names
- Curly Braces: To Cuddle or Not
- Kent Beck’s Software Design Rules
Please Subscribe to our YouTube channel to get notification for upcoming recording.
If you are new in Salesforce. Please check our free Salesforce Admin and Salesforce Developer training.
Thanks,
Salesforce Apex Hours

Amit Chaudhary is Salesforce Application & System Architect and working on Salesforce Platform since 2010. He is Salesforce MVP since 2017 and have 17 Salesforce Certificates.
He is a active blogger and founder of Apex Hours.
Comments(3)
karthik donthu says:
June 27, 2020 at 12:10 pmHey Amit,
When is this session
Can you please share registration link i dont find any where
Amit Chaudhary says:
June 27, 2020 at 1:32 pmNo registration required this will live steam on YouTube https://www.youtube.com/watch?v=wQjsneX5XbQ
Chris says:
February 16, 2021 at 12:53 pmHey Amit
Nice video. At about the 20 minute mark in the youtube recording it looks like there is a bug in setCategory, if Amount = 50000 you don’t set the category.
Chris