Guideline for writing cleaner PHP coding

There are several benefits of writing clean code for any project , no matter how small it is. The main benefit is that when you want to edit and read it after a long break then you can get an idea instantly about code. And in addition it helps in editing your code and especially when you need to find an error. Please find some guidelines for writing cleaner PHP coding :

• Be relevant to the module
• Give meaningful names
• Use white space
• Modulize with classes
• Make constant with care

You forgot the most important part of coding, I don’t care how ugly the code looks, or how much white space my coders use. If your not commenting your code your going to regret it later. Comments are by far the most important part of any coding.

I have a love/hate relationship with commenting. A good coder rarely needs to read comments. The code speaks for itself. If you can’t read the code then I highly doubt comments will help. I still try to comment as much as possible but unless I know someone else needs to read it, why bother?

You bother because unless your never going to work with another individual on your site it makes location of functions within a script easier. If you have ever had to debug a 1000 line script without any comments you will understand. Comments are essential even if you do not need them to know what the code says it’s like road signs. 9 time out of 10 you know where your going and don’t need them but when you do need them and their not their it is a real pain in the butt.

Sponsor our Newsletter | Privacy Policy | Terms of Service