Developer Quiz: What are coding standards that do not get applied?
- More free-time on weekends.
- A non maneuvering ship on the Atlantic Ocean.
- A present for president.
Well, probably it might be any of these. But what you can say for sure is, that a coding standard that does not gets applied is not a coding standard at all. That simple it is.
And if the age of code is the excuse for not having it following the standards, then this is just a very lame excuse for being lazy/not having a coding standard.
Automated Testing or not?
The coding standard example is one of those simple but aching misuse of programming tools and techniques. Another good example is the broken testsuite. Having a broken testsuite is more bad than having none. That simple it is.
Spare your project the overhead if you really can not manage an automated testsuite properly. Throw it in the bin. I can understand that this is a hard step as it implies to question all efforts already done in testing. But it only introduces code and work while not giving you anything but a whole bunch of unanswerable questions. And – surprise, surprise – broken testuites just do not attract any developers to write new tests. Writing patches for a testsuite that throws more fails then you can count is just a very unthankful; not to say foolish job.
Example: WordPress Automated Testing results over time
|3. Nov 2010||505
|15. May 2010||489||2919
|22. Feb 2010||489||2879||128||54||18|
Source: hakre on wordpress, see also.
So when a project is not able to run a testsuite then it should not create the image that it is doing so. That’s just counter productive, even if testing is a well accepted thing in development. Just don’t do it for the others, do it or don’t do it for yourself.
Live with your coding style and your non-test-driven development and be proud of it. Otherwise you’re just introducing complexity that hinders you learing about the real problemstm your project has.
Coding Standards FAQ Style
When does it make sense to have coding standards? — It makes sense to have coding standards from the moment there is more then one coderette handling the chunks, so any project with more than a single developer. You normally automatically create a sort of coding standard when you first-time share the code with another developer and he shares his impressions on coding style with you.
Must coding standards be complicated? — Not at all! In fact, the standards should be very easy to adopt. Like when a new developer looks into a file of a project for the first time it should be immediately clear to her what the coding standards are because the code is properly formatted.
Is it okay to use tools to follow the standards? — Absolutely. There is no rule that every single char has to be written manually and it does not make the coding standard less better if a developer uses a tool like a code formatter. Just keep in mind that if it is a need to follow the coding standard to use specific tools all the time you might have the wrong coding standard because it is a too complicated thing.
Should Coding Standards be written down? — The code should already show the coding standard which normally means it’s documented. If you experience unclear cases in your project, you can write those down giving examples of how to do / not to do things. But keep things simple, it’s a tool that should be accessible for developers and not a complicated science to deal with.
How can I find out if the coding standards are followed in my project? — There are tools and utilities that can be automated to constantly check your codebase and report back to you if there is a glitch or everything is still in order. That spares you a lot of time to check the code manually. This is something useful to have when your project has about five or more developers. For PHP such a tool is the PHP Code Sniffer.
Image Credits: Tower of Babel by Lucas van Valckenborch; 1594; via KoS
- PHP Code Sniffer, Eclipse and WordPress (6 Mar 2010; by hakre)
- Coding Standards Summary of the last Week (28 Jan 2010; by hakre)
- Horde Coding Standards (via web developer’s blog)