schlitt.info - php, photography and private stuff ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ :Author: Tobias Schlitt :Date: Wed, 19 Nov 2008 23:29:46 +0100 :Revision: 1 :Copyright: CC by-nc-sa ================================================== studlyCaps or under_scores in PHP5's OO interface? ================================================== :Description: The big question for PHP5 currently is the discussion around the new dual-syntax system, which allows extensions to be used with a procedural and an object oriented interface. The problem is, that PHP usually uses "_" to devide parts of a function name, where most OO languages (e.g. Java, C#,...) use studlyCaps to divide method name parts. And this is the common way in OO programming with PHP, too (as we from PEAR defined once upon a time...). The big question for `PHP5`__ currently is the discussion around the new dual-syntax system, which allows extensions to be used with a procedural and an object oriented interface. The problem is, that PHP usually uses "_" to devide parts of a function name, where most OO languages (e.g. `Java`__, `C#`__,...) use studlyCaps to divide method name parts. And this is the common way in OO programming with PHP, too (as we from PEAR defined once upon a time...). There was (and I guess already is) a `big discussion`__ on the PHP `internals mailinglist`__ about that issue and PHP internal developers ran into a heavy guerilla war about that issue. `John Coggeshall`__ recently called for comments from the PHP userland on `his blog`__, what I guess is a pretty good idea, since PHP users will have to live for a long time. In my personal opinion, PHP's OO interface should stick to the standards which were defined by PEAR. Usually PEAR follows inventions of PHP, the PHP guys now should one time follow PEAR. In general the "foo_bar against fooBar" discussions seems to result in a matter of personal favor. There are many arguments for and against each style, but I guess the most effective argument is what users want. IMHO, most OO PHP users should be used to the studlyCaps way and for that PHP itself should use it. No matter if methods then do not look like functions, but indeed, they aren't the same. But take your own picture on `John's Weblog`__, the `PHP internals thread`__ and your personal experiences and leave a comment here or on `John's blog`__. .. __: http://www.php.net .. __: http://java.sun.org .. __: http://msdn.microsoft.com/vcsharp/ .. __: http://marc.theaimsgroup.com/?l=php-dev&m=107048471805832&w=2 .. __: http://marc.theaimsgroup.com/?l=php-dev .. __: http://www.coggeshall.org/ .. __: http://blog.coggeshall.org/archives/113_PHP5_What_do_you_Think_of_studlyCaps.html .. __: http://blog.coggeshall.org/archives/113_PHP5_What_do_you_Think_of_studlyCaps.html .. __: http://marc.theaimsgroup.com/?l=php-dev&m=107048471805832&w=2 .. __: http://blog.coggeshall.org/archives/113_PHP5_What_do_you_Think_of_studlyCaps.html .. Local Variables: mode: rst fill-column: 79 End: vim: et syn=rst tw=79 Trackbacks ========== Comments ======== - Chris Shiflett at Tue, 23 Mar 2004 23:44:35 +0100 I agree with you that fooBar should be used, but only for the sake of consistency. I don't agree with the argument that PHP should follow PEAR conventions as a way to repay some past favor (PEAR using PHP conventions). - Toby at Tue, 23 Mar 2004 23:51:42 +0100 Just to clearify: I did not mean that PHP should follow PEAR because of some historical reasons. Just because of the fact that a standard has been implemented for OO style PHP programming. - galactica at Fri, 26 Mar 2004 09:08:48 +0100 But php is not object oriented at the basement it is like c++ you can program with the case that you want, and it is the drawback of php. And the fact OO orienting it is full of nonsense to my advice. - Toby at Fri, 26 Mar 2004 09:19:54 +0100 @galactica: But what has this to do with the studlyCaps discussion?