News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Paul Jones' Blog:
Regarding Underscores
October 21, 2010 @ 10:47:25

In response to a post from Leszek Stachowski about underscores in PHP class development, Paul Jones has shared his own thoughts on the matter - that he disagrees with Leszek and suggests keeping the underscore prefix for private methods.

I think the underscore-prefix for protected and private is a good convention to keep. As with many things about programming, this convention is not for the program, it is for for the programmer. For example, limiting your line length to about 80 characters is a good idea, not for reasons of "tradition", but because of cognitive limitations of human beings who have to read code. Likewise, using the underscore prefix is an immediate and continuous reminder that some portions of the code are not public. Its purpose is as an aid to the programmer.

He suggests that it offers something similar to the thought process behind the magic methods like __get or __set that both work on a private scope. Check some of the comments for opinions both for and against the idea from other community members.

0 comments voice your opinion now!
underscore opinion private convention programmer


blog comments powered by Disqus

Similar Posts

Jani Hartikainen's Blog: A simple way to make your code better: Stop adding more parameters

Padraic Brady's Blog: Unit Testing: One Test, One Assertion - Why It Works

Zend Developer Zone: Zend Certified Engineers Hangout at oDesk

Brandon Savage's Blog: How To Win Developers and Influence Code Quality

Indra Dutta's Blog: Top 5 reasons why PHP is a better choice than java & .NET for most websites


Community Events





Don't see your event here?
Let us know!


composer language library tool series update interview package security framework symfony introduction podcast voicesoftheelephpant opinion laravel community application version release

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework