You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by Frank Zhang <Fr...@citrix.com> on 2013/02/15 23:11:56 UTC

[Discuss] Name convention of class variable

Current name convention of class variable in CloudStack is prefixing variable name with a '_', for example

Class SomeManagerImpl {
	private long _myVar;
}

I know this is widely spread convention but I really think it's dated. First time I saw it is in the famous book "Programming in Java Language", it helps you to distinguish class variable and variable defined in function in PLAIN text editor.
But nowadays everybody writing code in IDE like Eclipse and every IDE highlights these variables in vivid color, there is no needs to use underscore anymore.

And this convention has a significant disadvantage that is broken Java Bean style. A Java bean is a class with setter/getter, I always use Eclipse's shortcut "Alt+Shift+S

RE: [Discuss] Name convention of class variable

Posted by Edison Su <Ed...@citrix.com>.
+1, no _, during the refactor, I removed all the _ as much as I can already.

> -----Original Message-----
> From: Frank Zhang [mailto:Frank.Zhang@citrix.com]
> Sent: Friday, February 15, 2013 2:12 PM
> To: cloudstack-dev@incubator.apache.org
> Subject: [Discuss] Name convention of class variable
> 
> Current name convention of class variable in CloudStack is prefixing variable
> name with a '_', for example
> 
> Class SomeManagerImpl {
> 	private long _myVar;
> }
> 
> I know this is widely spread convention but I really think it's dated. First time I
> saw it is in the famous book "Programming in Java Language", it helps you to
> distinguish class variable and variable defined in function in PLAIN text editor.
> But nowadays everybody writing code in IDE like Eclipse and every IDE
> highlights these variables in vivid color, there is no needs to use underscore
> anymore.
> 
> And this convention has a significant disadvantage that is broken Java Bean
> style. A Java bean is a class with setter/getter, I always use Eclipse's shortcut
> "Alt+Shift+S

RE: [Discuss] Name convention of class variable

Posted by Frank Zhang <Fr...@citrix.com>.
Sorry, wrongly sent former one by mistake.

Current name convention of class variable in CloudStack is prefixing variable name with a '_', for example

Class SomeManagerImpl {
	private long _myVar;
}

I know this is widely spread convention but I really think it's dated. First time I saw it is in the famous book "Programming in Java Language", it helps you to distinguish class variable and variable defined in function in PLAIN text editor.
But nowadays everybody writing code in IDE like Eclipse and every IDE highlights these variables in vivid color, there is no needs to use underscore anymore.

And this convention has a significant disadvantage that is broken Java Bean style. A Java bean is a class with setter/getter, I always use Eclipse's shortcut "Alt+Shift+s" to call "Generate getter and setter ..."
Then variable with '_' leads to below setter/getter:

Class SomeManagerImpl {
	private long _myVar;

	public void set_myVar(long _myVar) {
                }

                public long  get_myVar() {
                }
}

So, I suggest obsoleting this convention, don't prefix a '_' anymore.

> -----Original Message-----
> From: Frank Zhang
> Sent: Friday, February 15, 2013 2:12 PM
> To: cloudstack-dev@incubator.apache.org
> Subject: [Discuss] Name convention of class variable
> 
> Current name convention of class variable in CloudStack is prefixing variable
> name with a '_', for example
> 
> Class SomeManagerImpl {
> 	private long _myVar;
> }
> 
> I know this is widely spread convention but I really think it's dated. First time I
> saw it is in the famous book "Programming in Java Language", it helps you to
> distinguish class variable and variable defined in function in PLAIN text editor.
> But nowadays everybody writing code in IDE like Eclipse and every IDE
> highlights these variables in vivid color, there is no needs to use underscore
> anymore.
> 
> And this convention has a significant disadvantage that is broken Java Bean
> style. A Java bean is a class with setter/getter, I always use Eclipse's shortcut
> "Alt+Shift+S

Re: [Discuss] Name convention of class variable

Posted by Wido den Hollander <wi...@widodh.nl>.

On 02/15/2013 11:11 PM, Frank Zhang wrote:
> Current name convention of class variable in CloudStack is prefixing variable name with a '_', for example
>
> Class SomeManagerImpl {
> 	private long _myVar;
> }
>
> I know this is widely spread convention but I really think it's dated. First time I saw it is in the famous book "Programming in Java Language", it helps you to distinguish class variable and variable defined in function in PLAIN text editor.
> But nowadays everybody writing code in IDE like Eclipse and every IDE highlights these variables in vivid color, there is no needs to use underscore anymore.
>

I don't mind it being changed, but I for example do not work with an IDE 
like Eclipse but use Kate (KDE) to do my work in.

I know that others use just plain vim.

Wido

> And this convention has a significant disadvantage that is broken Java Bean style. A Java bean is a class with setter/getter, I always use Eclipse's shortcut "Alt+Shift+S
>