Page 1 of 2

Your coding future decided in hilarious, yet acrimonious way

Posted: Thu Jun 04, 2009 10:52 pm
by Christopher
I don't know if many of you have heard about this or care. It seem that a number of guys from the major frameworks got together at php|tek and put together a "PHP coding standards" specification. Most of the ideas are pretty good, but they unwittingly presented it in disastrous fashion. Things went downhill from there. It is pretty funny to read, and very informative to anyone who is interested in PHP at that level (or planning to organize a standards group!).

I don't know whether these guys have taken their discussion off-list after their amazing launch. Read it and weep:

http://news.php.net/php.standards/start/2

Re: Your coding future decided in hilarious, yet acrimonious way

Posted: Fri Jun 05, 2009 2:30 am
by jaoudestudios
Most of the ideas are pretty good, but they unwittingly presented it in disastrous fashion
Totally right, definitely a disastrous fashion! But good ideas.

I am currently redoing my website with a colaborative feel to it (hopefully go live next week). I am trying to put together a good coding practice standards section for the web technologies/languages I use and other developers I colaborate with. However, I did not take into consideration namespaces yet.

Btw does anyone know when php 5.3 and/or php 6 is going to be released?

Re: Your coding future decided in hilarious, yet acrimonious way

Posted: Fri Jun 05, 2009 11:12 am
by Benjamin
All classes, interfaces, and abstracts must begin with an uppercase
character.
B.S. I see no reason to make that a standard.

That's scary stuff. It doesn't seem like they are really putting a lot of thought into anything.

Re: Your coding future decided in hilarious, yet acrimonious way

Posted: Fri Jun 05, 2009 12:11 pm
by Christopher
They were certainly trying to tackle an important problem -- autoloading that understands namespaces. I don't know if the effort has died or they have just taken the discussion private. But it should be a warning to any open source standards effort that starts with "we have decided X, Y and Z already..." ;)

Re: Your coding future decided in hilarious, yet acrimonious way

Posted: Fri Jun 05, 2009 12:31 pm
by Darhazer
PHP and Coding Standards? Well, first there should be a naming convension for the build-in function, and then they can talk about Coding Standards...
hexdec but bin2hex
str_replace but strcasecmp
isset but is_numeric
strcasecmp for case insensitive comparision, but str_ireplace for case insensitive replace
And of course, stdClass but Exception :-)


:offtopic:
php.net wrote:5.3.0 This function is no longer deprecated, and will therefore no longer throw E_STRICT warnings.
5.0.0 This function became deprecated in favour of the instanceof operator. Calling this function will result in an E_STRICT warning.

Re: Your coding future decided in hilarious, yet acrimonious way

Posted: Fri Jun 05, 2009 12:37 pm
by onion2k
Is that how they're actually presenting the ideas to the public, or is that just a link to an email discussion list?

Re: Your coding future decided in hilarious, yet acrimonious way

Posted: Fri Jun 05, 2009 12:37 pm
by jayshields
Darhazer wrote:PHP and Coding Standards? Well, first there should be a naming convension for the build-in function, and then they can talk about Coding Standards...
hexdec but bin2hex
str_replace but strcasecmp
isset but is_numeric
strcasecmp for case insensitive comparision, but str_ireplace for case insensitive replace
And of course, stdClass but Exception :-)
Good points. The worst of all is the needle and haystack parameter order confusion.

Re: Your coding future decided in hilarious, yet acrimonious way

Posted: Fri Jun 05, 2009 12:42 pm
by Christopher
onion2k wrote:Is that how they're actually presenting the ideas to the public, or is that just a link to an email discussion list?
The first couple postsare the presentation of the decisions that a small group of guys from frameworks made at the php|tek conference. The whole discussion shows the think blowing-up. I don't know what is going on now as the conversation seems to have stopped there a day or two ago. I assume they have taken the discussion private. I hear that they kicked people off of one the the PHP IRC channels for no reason the other day.

It is a standard that will effect PHP programmers in general. The idea is for frameworks to be more interoperable by using common loading/autoloading standards. That is one reason I posted the link.

Here are some more links:
http://www.leftontheweb.com/message/The ... initiative
http://www.travisswicegood.com/index.ph ... ards-group
http://pooteeweet.org/blog/0/1499

Re: Your coding future decided in hilarious, yet acrimonious way

Posted: Fri Jun 05, 2009 2:26 pm
by Weirdan
astions wrote:
All classes, interfaces, and abstracts must begin with an uppercase
character.
B.S. I see no reason to make that a standard.
Uppercasing class names is pretty much THE standard already.

Re: Your coding future decided in hilarious, yet acrimonious way

Posted: Sat Jun 06, 2009 5:36 am
by jaoudestudios
Weirdan wrote:
astions wrote:Uppercasing class names is pretty much THE standard already.
Yep, it is in CakePHP and Zend FrameWork

Re: Your coding future decided in hilarious, yet acrimonious way

Posted: Sat Jun 06, 2009 9:31 pm
by volomike
Me:

{Legend: ProperCase, UPPERCASE, Proper_Score_Case, UPPER_SCORE_CASE, camelCase, camel_Score_Case}

* Class Names: ProperCase except when trying to show domain grouping, such as Employer_Settings and Employer_ControlPanel, which would sort of use a modified Proper_Score_Case.

* Function/Class Method Names: camelCase. (Note -- I only finally decided to switch this year to this, even though it is completely illogical to me. (I'm Old School.) I just wanted to, well, fit in with the New School kids.)

* Constant Names: UPPERCASE where readable, and UPPER_SCORE_CASE where it may read better, on a case-by-case basis.

* Opening Curly Brace: Same line as declaration, always.

* Closing Curly Brace: Shares same indentation as declaration.

* Variable Names: ProperCase but with prefixes ($sFirstName, $oRec, $aoRecords) unless $a, $b, $c, or $i, $j would work in some cases. Prefixes:

g + prefixes = global (so people don't ask, "Where did this variable come from?" -- and used sparingly)
x + prefixes = byref var (meant to return a value back)
a + prefixes = array
rs = recordset
rw = row
s = string
v = variant (any) -- used extremely sparingly
o = object
b = boolean
c = single character
d = date, date/time, time
h = handle
n = numeric (any kind)

(With some minor exceptions on the ProperCase such as: $hDB, $nID, $sIPAddress.)

Also, if I instantiate a class, I am inclined to go without using variable prefixes unless I have a factory item. Example:

$oRec = $DB->getRecord('users','id = 1'); // factory item; used even if getRecord may instantiate a class like ActiveRecord to return it
$Settings = new Settings(); // class item

I also don't buy the common argument, "PHP is a duck-typed language. Using variable prefixes is irrelevant." That's hogwash. I use them even though I'm well aware the language is duck-typed. I use them to let people know I'm really meaning for something to be considered as that variable type. I mean, there's a big difference in the values between:

$bAnswer
$sAnswer
$nAnswer

It makes the code a lot more intuitive when shared with others using variable prefixes.

Note I have started to also carry this forward in my Javascript/jQuery stuff as well.

Re: Your coding future decided in hilarious, yet acrimonious way

Posted: Sun Jun 07, 2009 3:35 am
by onion2k
The entire point of a coding convention is to make you code better with fewer errors. That's it. Anyone who hasn't read Joel Spolsky's article on naming conventions really has no place posting in this thread: http://www.joelonsoftware.com/articles/Wrong.html His point is very straightforward - your variable prefix should tell you what the variable contains in the context of your code. It's not good just having n for every number. That won't tell you that the variable has to contain a money value for example. Using "money" as a prefix, or, I suppose, "nMoney" would make much more sense.

Re: Your coding future decided in hilarious, yet acrimonious way

Posted: Sun Jun 07, 2009 7:03 am
by volomike
Onion - sent you a PM. Thanks.

Re: Your coding future decided in hilarious, yet acrimonious way

Posted: Mon Jun 08, 2009 1:00 am
by Daz
onion2k wrote:Anyone who hasn't read Joel Spolsky's article on naming conventions really has no place posting in this thread: http://www.joelonsoftware.com/articles/Wrong.html
Awesome link - many thanks!

Re: Your coding future decided in hilarious, yet acrimonious way

Posted: Mon Jun 08, 2009 2:04 am
by matthijs
Great article. He makes some good points, definitely made me think about ways to improve coding conventions

Why are so few people using Hungarian notation anyway?