Login   Register  
PHP Classes
elePHPant
Icontem

PHP standards

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      PHP Classes blog  >  Do PHP Developers Nee...  >  All threads  >  PHP standards  >  (Un) Subscribe thread alerts  
Subject:PHP standards
Summary:Yes!
Messages:4
Author:Jack Rowe
Date:2012-06-04 20:16:25
Update:2012-06-05 01:53:46
 

  1. PHP standards   Reply   Report abuse  
Picture of Jack Rowe
Jack Rowe
2012-06-04 20:19:42
I'm all for the adoption in the php community of coding standards at least as they relate to code readability. There is a large amount of sharing in the php community, and many offered scripts haven't even been refactored and/or lack descriptive method and property names, etc. This makes the sharing that our community is famous for problematic.

I think it is also a reason php is still looked down upon by practitioners of other languages, and also a reason that professional coders still rarely explain high-level concepts in php, instead choosing java or one of the C languages.

I don't think frameworks are the answer as they'd require universal adoption to be effective.

Exciting changes are occurring in software architecture now, and for php'ers to incorporate these ideas will require meeting a much higher set of coding standards to increase readability to the extent we can share these higher-level concepts among ourselves.

  2. Re: PHP standards   Reply   Report abuse  
Picture of Brian Clancey
Brian Clancey
2012-06-05 00:39:30 - In reply to message 1 from Jack Rowe
I have always tried to code in PHP the same that way that I code in C or C++.

Most of the time, coding standards seem to be standards over coding style -- things like using CamelCase and the placement of braces to truly revolve around personal preference.

Unfortunately, just because code strictly follows standards does not mean it is readable, comprehendable, runnable and/or unbreakable.

To my mind, the first objective of coding standards should be security. This includes preventing memory leaks, sanitizing user input, initializing variables, and so forth. Visual style is secondary.

  3. Re: PHP standards   Reply   Report abuse  
Picture of Jack Rowe
Jack Rowe
2012-06-05 01:53:20 - In reply to message 2 from Brian Clancey
Good points, Brian... I'm thinking more along the lines of clear architecture, DI over globals to clarify object relationships and natural language naming than caps or white space in the readability issue, but I agree the security/memory/etc issues you mention might be better or more foundational places for actual standards to start... standards prob can't reach very far into architectural issues anyway, but at least as far as DI and naming.

  4. Re: PHP standards   Reply   Report abuse  
Picture of Manuel Lemos
Manuel Lemos
2012-06-05 01:53:46 - In reply to message 2 from Brian Clancey
You are right, many of the so called coding standard rules are just personal preferences that at least half of the community will reject, like the matter of tabs versus spaces.

I also agree that following code standards is not a guarantee to make the code readable. For instance, some developers seem to lazy or trying to save memory in places that it does not matter like the names of the variables and functions.

If they used meaningful names instead of short names the code would be more readable than using standards compliant case rules.

I am just not sure how do you want to define standards that prevent security problems.