[wp-hackers] Coding style

Brian Layman Brian at TheCodeCave.com
Tue Jul 4 01:25:42 GMT 2006


BL>> The one thing I would change is that I think this topic should 
BL>> specifically mention the convention for naming functions,
variables, 
BL>> and constants.  PEAR specifies that here: 
BL>> http://pear.php.net/manual/en/standards.naming.php and it is
probably 
BL>> one of the most important areas to cover, since all of that stuff
is 
BL>> case sensitive and is easily overlooked when debugging.
RD> functions and class names aren't case sensetive. 

Yes, I shouldn't have said "all that stuff" since I mentioned functions.
Even so, since functions are not case sensitive it just means that the
author could be inconsistent without the punishment of code errors.


RD>>I can't think of a single variable in the WP source off hand that
has an uppercase letter in it. 
RD>Touché. With the exception of *ID, I can't think of anything (* waits
for someone to prove him wrong again)

Now, if I couldn't find anywhere that the standard was broken in the WP
code, it would only be stronger that it is a standard that SHOULD be
followed in future code and thus noted on the Coding Styles page.

But if you do want examples of where it is not followed, here are the
first few that I've found:
wp-admin\admin-functions.php
startPos
endPos

wp-admin\cat-js.php
ajaxCat
moveIt
catString
fixedExplode
currentElement

wp-admin\options-permalink.php
allElements
inputColl

Plugins have them too...
buttonsnap.php
function TinyMCE_buttonsnap_parseAttributes(attribute_string) {
   var attributeName = "";
   var attributeValue = "";
   var withInName;
   var withInValue;
   var attributes = new Array();
   var whiteSpaceRegExp = new RegExp('^[ \n\r\t]+', 'g');
   var titleText = tinyMCE.getLang('lang_buttonsnap_more');
   var titleTextPage = tinyMCE.getLang('lang_buttonsnap_page');


The primary warring standard seems to be what Mr. Miller called
camelCase: first letter lowercase, subsequent words proper case. 

There is another standard in the code of underscores between all words
and the some_ID variables follow yet another standard...

If you really want to throw the coder for a loop, just ask them what to
do with TinyMCE related functions and variables!

Anyway, I think it is worth mentioning how variables should be handled.

For your edification, I'll get back to you on the tabs in editors.  I've
got kids wanting bedtime stories ATM.

______________________________________________
Brian Layman 
http://www.TheCodeCave.com



More information about the wp-hackers mailing list