Go Back   SitePoint Forums > Forum Index > Program Your Site > PHP > PHP Application Design
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Old May 4, 2006, 02:31   #1
dagfinn
SitePoint Guru
 
dagfinn's Avatar
 
Join Date: Jan 2004
Location: Oslo, Norway
Posts: 895
Question How to determine code quality in PHP

Following up on the "utter disgrace" thread, how about discussing what kind of code we want to see in open source projects. Mostly I think I know good code from bad when I see it, but my criteria might be idiosyncratic. I seem to remember selkirk posted something relevant to this a while ago, but I couldn't find anything in a quick search. Also, this is a relevant objection:

Quote:
Originally Posted by CapitalWebHost
I see a lot of postering in this thread...most of i comes of as primadonna type of code bashing.

Instead of just bashing code ramdomly, why not explain to others reading this thread that are not "God Gifted Programmer" why the code is bad?
I tend to look for the following:
  • Classes. "The more, the better" may be a stupid over-simplification, but my impression is that with existing projects, it's a pretty good indicator of quality. And up to a certain point, it is the inverse of the "large class" code smell.
  • Unit tests. The few projects who actually have unit tests are clearly likely to have better code. Of course, the next criterion will be actual coverage, as opposed to assertEqual(2+2,4)
  • No deep nesting of conditionals and loops. To a certain extent, this may be a matter of taste, but I would think that anything more than two levels is a negative indicator, since it's likely to be hard to unit test.
  • Naming. For example, if the average length of variable names is less than 1.5, there's a problem.
This is just my personal list off the top of my head. I know there are fancier, more academic criteria as well. And there's security, which is a separate set of concerns, but obviously important.
dagfinn is offline   Reply With Quote
 

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Sponsored Links
 
Forum Jump


All times are GMT -7. The time now is 23:40.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved