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

Reply via email to