PHP code is powerful and flexible. This means that anyone who writes code should be a bit more responsible and write code with good practices. Otherwise the resulting code, while functional, will be a hopeless tangled mess that cannot be deciphered by anyone.
Name it right – Avoid any half-baked names that seem convenient at the time. When you are on a roll with coding this may seem hard to do, but try to do it because it will make you a better programmer and your code much easier to read. For example, use a descriptive name like ‘findNextWorkingDay’ and avoid names likes ‘fnxtwrkd’.
Pace it out – Sometimes it easy to get excited about the codeand get to work on it right away. This usually results in long blocks of code being written at a stretch. Avoid this and break down the problem into little parts. Write small blocks of code that take care of one of these little parts. This will make you code more secure and once again, easier to understand.
Documentation – Documentation of the code really refers to what the code should achieve. Most people try to write what the code is actually doing and this is not the intention of documentation. If you followed the previous two tips, then documentation will become really easy.
Fix your errors –Always ensure that your code contains enough measure to combat all foreseeable errors. Typically, only twenty percent of good code can be considered to do what the code is supposed to do. The balance eighty percent is there to combat errors and take care of validations.
Posted By: CSCL2002