For anyone who codes a program, it is important to not just have a working program, but to have a program that is easy to understand, whether you publish your program onto github, or you want to review your program after finishing it. Clean code is a term that was first introduced by Robert Cecil Martin, also known as Uncle Bob. He wrote a book that gives best practices and tips for writing understandable and working code.
When creating formulas for writing code, instead of including numbers in a formula, which could lead to confusion for a number’s purpose in a calculation. Creating a variable that explains it’s purpose in a code makes calculation clear. Comments can explain the meaning of a statement in a code, and while comments can attempt to clear up any confusion for anyone viewing code, it should not be used to explain a obvious statement, but to explain certain actions in code. For constructing functions, it’s best to have a function perform one action, and if a function is very lengthy, a function should be broken down into multiple functions.
When writing code with multiple nested if else conditions, to make a program easier to understand, if else conditions should be split into descriptive functions. As someone who has worked with different programming languages, I would want to use the practices of clean code, to write a working program that I can review and understand if i revisit my work.
What Is Clean Code? A Guide to Principles and Best Practices
From the blog CS@Worcester – jonathan's computer journey by Jonathan Mujjumbi and used with permission of the author. All other rights reserved by the author.