Win All The Chicks By Sticking To Coding Standards
Posted on 19/6/07 by Tim Koschützki
Coding Standards are extremely important in programming environments. They not only allow you to build a consistent code base, but also make your overall life a lot easier. Join me and find out how you can lay out the foundation for your new car/house/chick.
Five Reasons Why You Should Stick To Coding Standards
1. You Will Have A Consistent Codebase
Coding Standards help you have a consistent code base. If everything looks similar, you will easily feel home looking at your code. Try it out today and you will see for yourself that you feel much more motivated if everything looks clean and in shape. Programming is such a sophisticated task. Don't work hard - work smart! Use every tool available to make your life easier. Enforcing code conventions is one such tool.
2. You May Not Get The Help You Deserve
If you are in irc channels or on forums, you will be represented by your code. If you are in desperate need of help, people will want to see some of your code. If your code looks cumbersome and inconsistent, people will ask you "gwaa..refactor that code first young grashopper!", which takes time to repost on the forum (for example). Do it right the first time, save some time, present yourself in a better way and finally get the help you deserve.
3. Clean Code Prevents Hair Loss
I cannot count the number of times when I looked for a small typo in a PHP script back when I was very young and coding conventions meant as little as possible to me (half of that). Coding Conventions help your debugging. They allow you to scan your code and find parse errors and notices (possibly from uninitialized variables) a lot faster. In short, coding standards prevent hair loss later in your life. Studies tell that a programmer is using up at least one third of his time with debugging. Why should you make it unnecessarily uneasy?
4. Others Will Recognize Your Will To Write Good Code
This trully goes alongside 2. However, I want to emphasize it a bit more: If the person above you is a bit angry, because you forgot (again) to triple-test your code before you checked it in (or at least forgot to make all automatic tests pass), coding standards can help you rebuild your reputation. I notice it often in my workplace. When somebody checked some untested code in, he will try to really enforce coding conventions in his code so the person above us recognizes it. Of course, your chief programmer may be different, but generally, this should help a bit.
5. Coding Standards Will Help You With Your Next [Car|House|Chick]
If you can debug code faster, feel home editing your code, get all the help you deserve and people recognize your good intentions you will feel a lot more relaxed. You will have fun with your work, with your colleagues and all other things in your life. This is the ultimate foundation for more money, general success, your new car or a new woman in your life. Okay, the latter may apply only to those who are feeling unlucky with their partner. :)
Use Coding Conventions and be happier in your life. :)
Which Coding Conventions Do You Recommend?
For this article I have looked at some sources for coding standards - especially to find out new ways of improving my own code. However, the ones that I use most often, at least in private projects (at my workplace I have to use others), are the ones from The CakePHP Foundation. Quelle surprise!
This document is simple and down to the point. For most coding situations there is a good way explained which formatting and intendation you should use. Please look at it and tell me what you think. I am eager to learn about new ways to organize my code. So should you.
Happy (clean) coding all!
You can skip to the end and add a comment.
Exactly my view Nate. Coding standards are so important - and very powerful in an OOP environment.
I find it odd that Coding Standards for PHP is an often ignored subject. I'm doing some freelance work right now and I guarantee the previous code monkey followed no standards at all. The code is a mish mash of bad programming concepts and repeated, redundant code. The app is very large and was developed over 2 years so there is no chance that I can rewrite it cleanly without breaking a whole lot.
I didn't realize CakePHP had a nice document on this or I'd have printed it out a long time ago.
This post is too old. We do not allow comments here anymore in order to fight spam. If you have real feedback or questions for the post, please contact us.
I really like the ones from CakePHP and it's what I use on all of my projects that are PHP based. Even if the app isn't inside of Cake - it still helps to keep your code clean and tidy.
I think these standards become much more helpful when you are writing OO code (private, public, protected). Even though PHP5 now provides you to declare your methods and variables as such - it is good practice to name them accordingly so that you can easily spot them in the rest of your code.