Clean code, Happy code.


Coding for nearly 6+ years, I can tell you from my experience, clean code is a must. Not a matter what you code, from a tiny program of 15 lines to huge one including thousands of lines, practicing clean code is necessary.


As a coder, you may think why you have to write clean code while you are just practicing. Well you answered your question. PRACTICE, which makes a man perfect. However, following are tips for coders today


1. Indentation: First rule of clean code for me, indentation. If your code is not properly indented, it is a mess for sure. Not only the other guy but also you will not recognize your code after completing another project. So it is a best practice to use proper indentation.


2. Naming Convention: One of the best practices for coding is using a static naming convention for functions, classes, variables, constants etc. Even file names should follow a convention. A good naming convention which is static for all the members team can help other easily understand what a variable for function name means. It should be used properly, and at least should not change in the middle of a project.


3. Commenting (Necessary Commenting): Commenting is another best practices for clean code. But keep in mind, unnecessary commenting will only increase lines and will make the code's readability harder.


4. Distinct convention for special words: Best practices include special words to be highlighted in a different way. For example, naming the constants with uppercase letters, naming the global variable with a preceding underscore (_) like $_system, uppercase letter for SQL query special words etc.


5. Documentation: It is quite like commenting but it has its own rules. Try to study open source code to understand how to write documentations for functions, class properties etc. So that reading those documentations you and other can easily understand what is the use of this properties, what are the parameters of this function, which parameters are required and which has default value. Well documentation is highly required in projects where multiple people are working where one user may use code written by another user.


These are only a few tips. As a coder you should find out good coding / coding standards and practice them even for a single line of code. Another post with more tips will arrive soon.


Happy Coding.