flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gordon Smith <gosm...@adobe.com>
Subject RE: Variable Naming Convention
Date Mon, 04 Nov 2013 18:36:00 GMT
> Here's an example of mine:

Your example didn't appear in the email.

> Currently I might name a local variable as 'm_variableName'

Naming local variables m_variableName is a bad idea, as "m" stands for "member" (i.e. instance).

The getter/setter convention used by the Flex framework is

private var _fooBar:int;

public function get fooBar():int
{
    return _fooBar;
}

public function set fooBar(value:int):void
{
    _fooBar = value;
}

In other words, the "backing variable" for a getter/setter starts with an underscore.

Local variables in the Flex framework don't start with anything special.

- Gordon


-----Original Message-----
From: Tintin [mailto:1955.mille.miglia@googlemail.com] 
Sent: Monday, November 04, 2013 5:23 AM
To: users@flex.apache.org
Subject: Variable Naming Convention

Hello

I am about to set sail on a new project and I thought I should try and improve my naming conventions
throughout the code. Bad habits are easily carried through from one language/project to the
next.

I'm particularly trying to nail down an acceptable (I realise that one person's 'acceptable'
makes another person mad) convention for local variable names and instance variable names
when employing Get and Set methods.

Currently I might name a local variable as 'm_variableName' and the instance variable as 'variableName'.
Some people precede the instance variable name with simply an underscore for the local variable.
It appears safe to assume a lowercase first letter and then capital letters for subsequent
'words' in the variable name.

Here's an example of mine:



Any thoughts very welcome.

Chris



--
View this message in context: http://apache-flex-users.2333346.n4.nabble.com/Variable-Naming-Convention-tp3517.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

Mime
View raw message