Sunday, 14 July 2013
A big Plus 1 for PHP Mess Detector a must tool for all php developers
I've been programming PHP for many years and some bad programming did creep in even though I try to learn and evolve my programming style as often as possible. When leaving my last job they got a company to come in and go over my projects to see if the company would out source the development of my projects.
This was the first time that I had ever had a proper code review of any work that I had done for the company. I was interested in what a outside developer would think of my work. I wasn't to scared that they would go "arrrgh what a pile of ...", so I thought of it as getting some constructive criticism of the projects. The first thing i have to say is in that one day I learnt so much it was amazing the first thing that the guy did was run my project through PHP mess detector (PHPMD.org).
PHP mess detector is a brilliant program it really does detect mess in your coding style. We have all done it when writing complex functions that have many nested if statements and loops. PHPMD scores each file and function for you, too many functions in a php class and your starting to get into the realm of messy code. To many conditions in your function with nested loops and your getting into complex functions which should be split up into multiple functions to make each part easier to read and the initial function easier to read as well as there is less code in it.
It is surprising how reformatting your code to pass PHPMD actually makes for more readable code. Go get it and run it against your projects then try to clean up your files to make them pass the tests. After one or two files you will understand what I mean.