SoccerGloves Posted March 17, 2011 Share Posted March 17, 2011 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 Quote Link to comment https://forums.phpfreaks.com/topic/230880-what-are-the-benefits-of-upper-camel-case-for-class-names-and-such/ Share on other sites More sharing options...
cssfreakie Posted March 18, 2011 Share Posted March 18, 2011 isn't this just a matter of consistency? As in choose a method and stick to it? That's what I always thought. not sure though Quote Link to comment https://forums.phpfreaks.com/topic/230880-what-are-the-benefits-of-upper-camel-case-for-class-names-and-such/#findComment-1189198 Share on other sites More sharing options...
Maq Posted March 18, 2011 Share Posted March 18, 2011 Most languages have a naming convention that you should adopt. The benefits seem small but will help more than you think. Here is a list of benefits: http://en.wikipedia.org/wiki/Naming_convention_%28programming%29#Potential_benefits Quote Link to comment https://forums.phpfreaks.com/topic/230880-what-are-the-benefits-of-upper-camel-case-for-class-names-and-such/#findComment-1189209 Share on other sites More sharing options...
thehippy Posted March 18, 2011 Share Posted March 18, 2011 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. Quote Link to comment https://forums.phpfreaks.com/topic/230880-what-are-the-benefits-of-upper-camel-case-for-class-names-and-such/#findComment-1189303 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.