Jump to content

what are the benefits of upper-camel case for class names and such?


SoccerGloves

Recommended Posts

Hi!

 

    I've seen many people use lower camel case (thisIsAnExample) for variable names, and upper camel case, also known as Pascal case  (ThisIsAnExample- sorry, I'm sure you know this already)  for class names, and possibly for method names and property names.

 

    But it seems simpler for me to just use all lower camel case.  If I use both, what good does it do?  And if I do use it, it brings up the question of "well, now what about the name of a library I write?  Or an entire piece of software?  Are those upper or lower?"  And it just seems simpler to do all lower.

 

But I don't want to walk over a cliff here, so if anyone thinks this is a bad idea please let me know! 

 

Thanks,

-Ryan

Link to comment
Share on other sites

Class and method naming should be part of an overall coding standard [or style], that makes your code readable and maintainable.  The PEAR Coding Standard is pretty much the matriarch of all the PHP coding standards, Zend and Doctrine use similar guidelines with a few variations, there are more and I'll leave you to find them on your own.

 

Apart from a coding standard, with consistent naming conventions it makes reflection a bit easier, it makes apidoc's legible and it doesn't make other programmers tear out their own hair while reading your code.

 

I don't know if many programmers do this, but I have a check-in script for my subversion repositories that does a check on my code.  The script firstly does a php -l [lint] test to make sure the file is valid php and then I do a style check with php_codesniffer to make sure my code passes the Zend style guidelines.

 

With 5.3 having namespaces and the bigger frameworks making use of them already, naming things have the distinct possibility of becoming very messy, very quickly.  Without a followed convention code may start to look like vomit instead of code.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.