Re: [Vala] "this" in objects



On Wed, Aug 03, 2011 at 10:57:16PM +0200, Jens Georg wrote:
On Mi, 2011-08-03 at 20:39 +0200, Pavol Klačanský wrote:
Hi,

why somebody uses this. prefix and somebody doesn't, I have tried and it 
worked with or without it

It's a matter of taste and or coding guidelines or explicitly avoid
shadowing of object members by local variables.

"this" can be used as an equivalent to the hungarian notation of m_foo
for members. 

You're completely free to use the style that suits you for your project.

Some projects use "_foobar" instead of "foobar" or "this.foobar" for 
private attributes. When reading code, it's important to know if it's a 
local variable or an attribute. So using "foobar" is not a good choice 
IMHO.

One advantage of "_foobar" is for completion. If we type "this.", we can 
get more results than "_", if the class is a subclass for example.

Attachment: pgpDbOdwvHOI8.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]