You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by Gary Gregory <ga...@gmail.com> on 2012/09/27 19:52:57 UTC

Static var name style

In v2 trunk, I see decls like:

private static LoggerContextFactory factory;

Which in my world should be:

private static LoggerContextFactory Factory;

As it is, it may not be possible to tell a static from an instance variable
(unless the ivar is prefixed with "this.")

For example, it is not possible with
org.apache.logging.log4j.AbstractLoggerTest.currentEvent

This makes groking the code harder.

Thoughts?

Gary

-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
JUnit in Action, 2nd Ed: <http://goog_1249600977>http://bit.ly/ECvg0
Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: Static var name style

Posted by Christian Grobmeier <gr...@gmail.com>.
On Thu, Sep 27, 2012 at 9:51 PM, Ralph Goers <ra...@dslextreme.com> wrote:
> For variable naming I have followed the default checkstyle rules.  To be
> honest, I can't recall seeing a variable before where the first letter was
> capitalized and the rest of it wasn't.  I'd have to look at the Sun naming
> guidelines or other references such as effective Java to see if that is a
> recommended practice.

+1

I really dislike uppercasing the first letter of a variable - static or not


>
> Ralph
>
>
>
>
>
> On Sep 27, 2012, at 10:52 AM, Gary Gregory wrote:
>
> In v2 trunk, I see decls like:
>
> private static LoggerContextFactory factory;
>
> Which in my world should be:
>
> private static LoggerContextFactory Factory;
>
> As it is, it may not be possible to tell a static from an instance variable
> (unless the ivar is prefixed with "this.")
>
> For example, it is not possible with
> org.apache.logging.log4j.AbstractLoggerTest.currentEvent
>
> This makes groking the code harder.
>
> Thoughts?
>
> Gary
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> JUnit in Action, 2nd Ed: http://bit.ly/ECvg0
> Spring Batch in Action: http://bit.ly/bqpbCK
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>
>



-- 
http://www.grobmeier.de
https://www.timeandbill.de

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Re: Static var name style

Posted by Gary Gregory <ga...@gmail.com>.
On Thu, Sep 27, 2012 at 5:38 PM, Ralph Goers <ra...@dslextreme.com>wrote:

> For reference -
> http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-135099.html#367
>
>
Well, it is indeed the guideline to lower case static vars, I still do not
like it ;) Grumble...

Gary


> Ralph
>
>
> On Sep 27, 2012, at 2:35 PM, Ralph Goers wrote:
>
> As I said, this is the first time I have ever seen the first variation. I
> am only familiar with the last two. Whenever I see a token starting with a
> capital letter it represents a class or interface name.
>
> I'm not objecting because I'm not willing to consider it (although with my
> IDE what you are requesting provides no value) but because I'm not familiar
> with anyone else doing it.  Can you point to any guidelines online that
> recommend this?  Can you confirm that checkstyle can be configured to
> support this.  If so, and no one objects, then I don't particularly care. I
> just don't want these changes made and then we have to deal with piles of
> checkstyle errors or potential developers who are questioning why we are
> being different.
>
> By the way - you do know that Jetbrains will give you a free license for
> IntelliJ just by telling them what ASF projects you work on - ;-)
>
> Ralph
>
>
> On Sep 27, 2012, at 2:20 PM, Gary Gregory wrote:
>
> There are three cases: static, final static, and instance.
>
> Usually they each get a visual cue in plain text as Static, FINAL_STATIC
> and instance.
>
> Gary
>
> On Sep 27, 2012, at 16:02, Paul Benedict <pb...@apache.org> wrote:
>
> I think Ralph is right. You are either doing UPPERCASE for constants or
> camelCase for non-constant values.
>
> Paul
>
> On Thu, Sep 27, 2012 at 2:51 PM, Ralph Goers <ra...@dslextreme.com>wrote:
>
>> For variable naming I have followed the default checkstyle rules.  To be
>> honest, I can't recall seeing a variable before where the first letter was
>> capitalized and the rest of it wasn't.  I'd have to look at the Sun naming
>> guidelines or other references such as effective Java to see if that is a
>> recommended practice.
>>
>> Ralph
>>
>>
>>
>>
>> On Sep 27, 2012, at 10:52 AM, Gary Gregory wrote:
>>
>> In v2 trunk, I see decls like:
>>
>> private static LoggerContextFactory factory;
>>
>> Which in my world should be:
>>
>> private static LoggerContextFactory Factory;
>>
>> As it is, it may not be possible to tell a static from an instance
>> variable (unless the ivar is prefixed with "this.")
>>
>> For example, it is not possible with
>> org.apache.logging.log4j.AbstractLoggerTest.currentEvent
>>
>> This makes groking the code harder.
>>
>> Thoughts?
>>
>> Gary
>>
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> JUnit in Action, 2nd Ed: <http://goog_1249600977/>http://bit.ly/ECvg0
>> Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK
>> Blog: http://garygregory.wordpress.com
>> Home: http://garygregory.com/
>> Tweet! http://twitter.com/GaryGregory
>>
>>
>>
>
>
>


-- 
E-Mail: garydgregory@gmail.com | ggregory@apache.org
JUnit in Action, 2nd Ed: <http://goog_1249600977>http://bit.ly/ECvg0
Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Re: Static var name style

Posted by Ralph Goers <ra...@dslextreme.com>.
For reference -  http://www.oracle.com/technetwork/java/javase/documentation/codeconventions-135099.html#367

Ralph

On Sep 27, 2012, at 2:35 PM, Ralph Goers wrote:

> As I said, this is the first time I have ever seen the first variation. I am only familiar with the last two. Whenever I see a token starting with a capital letter it represents a class or interface name.  
> 
> I'm not objecting because I'm not willing to consider it (although with my IDE what you are requesting provides no value) but because I'm not familiar with anyone else doing it.  Can you point to any guidelines online that recommend this?  Can you confirm that checkstyle can be configured to support this.  If so, and no one objects, then I don't particularly care. I just don't want these changes made and then we have to deal with piles of checkstyle errors or potential developers who are questioning why we are being different.
> 
> By the way - you do know that Jetbrains will give you a free license for IntelliJ just by telling them what ASF projects you work on - ;-)
> 
> Ralph
> 
> 
> On Sep 27, 2012, at 2:20 PM, Gary Gregory wrote:
> 
>> There are three cases: static, final static, and instance. 
>> 
>> Usually they each get a visual cue in plain text as Static, FINAL_STATIC and instance. 
>> 
>> Gary
>> 
>> On Sep 27, 2012, at 16:02, Paul Benedict <pb...@apache.org> wrote:
>> 
>>> I think Ralph is right. You are either doing UPPERCASE for constants or camelCase for non-constant values.
>>> 
>>> Paul
>>> 
>>> On Thu, Sep 27, 2012 at 2:51 PM, Ralph Goers <ra...@dslextreme.com> wrote:
>>> For variable naming I have followed the default checkstyle rules.  To be honest, I can't recall seeing a variable before where the first letter was capitalized and the rest of it wasn't.  I'd have to look at the Sun naming guidelines or other references such as effective Java to see if that is a recommended practice.
>>> 
>>> Ralph
>>> 
>>> 
>>> 
>>> 
>>> On Sep 27, 2012, at 10:52 AM, Gary Gregory wrote:
>>> 
>>>> In v2 trunk, I see decls like:
>>>> 
>>>> private static LoggerContextFactory factory;
>>>> 
>>>> Which in my world should be:
>>>> 
>>>> private static LoggerContextFactory Factory;
>>>> 
>>>> As it is, it may not be possible to tell a static from an instance variable (unless the ivar is prefixed with "this.")
>>>> 
>>>> For example, it is not possible with org.apache.logging.log4j.AbstractLoggerTest.currentEvent
>>>> 
>>>> This makes groking the code harder.
>>>> 
>>>> Thoughts?
>>>> 
>>>> Gary
>>>> 
>>>> -- 
>>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org 
>>>> JUnit in Action, 2nd Ed: http://bit.ly/ECvg0
>>>> Spring Batch in Action: http://bit.ly/bqpbCK
>>>> Blog: http://garygregory.wordpress.com 
>>>> Home: http://garygregory.com/
>>>> Tweet! http://twitter.com/GaryGregory
>>> 
>>> 
> 


Re: Static var name style

Posted by Christian Grobmeier <gr...@gmail.com>.
On Thu, Sep 27, 2012 at 11:35 PM, Ralph Goers
<ra...@dslextreme.com> wrote:
> As I said, this is the first time I have ever seen the first variation. I am
> only familiar with the last two. Whenever I see a token starting with a
> capital letter it represents a class or interface name.

Is also my understanding

> I'm not objecting because I'm not willing to consider it (although with my
> IDE what you are requesting provides no value) but because I'm not familiar
> with anyone else doing it.  Can you point to any guidelines online that
> recommend this?  Can you confirm that checkstyle can be configured to
> support this.  If so, and no one objects, then I don't particularly care. I
> just don't want these changes made and then we have to deal with piles of
> checkstyle errors or potential developers who are questioning why we are
> being different.

+1

>
> By the way - you do know that Jetbrains will give you a free license for
> IntelliJ just by telling them what ASF projects you work on - ;-)

And it is highly recommended to use IntelliJ!!

Cheers

> Ralph
>
>
>
> On Sep 27, 2012, at 2:20 PM, Gary Gregory wrote:
>
> There are three cases: static, final static, and instance.
>
> Usually they each get a visual cue in plain text as Static, FINAL_STATIC and
> instance.
>
> Gary
>
> On Sep 27, 2012, at 16:02, Paul Benedict <pb...@apache.org> wrote:
>
> I think Ralph is right. You are either doing UPPERCASE for constants or
> camelCase for non-constant values.
>
> Paul
>
> On Thu, Sep 27, 2012 at 2:51 PM, Ralph Goers <ra...@dslextreme.com>
> wrote:
>>
>> For variable naming I have followed the default checkstyle rules.  To be
>> honest, I can't recall seeing a variable before where the first letter was
>> capitalized and the rest of it wasn't.  I'd have to look at the Sun naming
>> guidelines or other references such as effective Java to see if that is a
>> recommended practice.
>>
>> Ralph
>>
>>
>>
>>
>> On Sep 27, 2012, at 10:52 AM, Gary Gregory wrote:
>>
>> In v2 trunk, I see decls like:
>>
>> private static LoggerContextFactory factory;
>>
>> Which in my world should be:
>>
>> private static LoggerContextFactory Factory;
>>
>> As it is, it may not be possible to tell a static from an instance
>> variable (unless the ivar is prefixed with "this.")
>>
>> For example, it is not possible with
>> org.apache.logging.log4j.AbstractLoggerTest.currentEvent
>>
>> This makes groking the code harder.
>>
>> Thoughts?
>>
>> Gary
>>
>> --
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org
>> JUnit in Action, 2nd Ed: http://bit.ly/ECvg0
>> Spring Batch in Action: http://bit.ly/bqpbCK
>> Blog: http://garygregory.wordpress.com
>> Home: http://garygregory.com/
>> Tweet! http://twitter.com/GaryGregory
>>
>>
>
>



-- 
http://www.grobmeier.de
https://www.timeandbill.de

---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org


Re: Static var name style

Posted by Ralph Goers <ra...@dslextreme.com>.
As I said, this is the first time I have ever seen the first variation. I am only familiar with the last two. Whenever I see a token starting with a capital letter it represents a class or interface name.  

I'm not objecting because I'm not willing to consider it (although with my IDE what you are requesting provides no value) but because I'm not familiar with anyone else doing it.  Can you point to any guidelines online that recommend this?  Can you confirm that checkstyle can be configured to support this.  If so, and no one objects, then I don't particularly care. I just don't want these changes made and then we have to deal with piles of checkstyle errors or potential developers who are questioning why we are being different.

By the way - you do know that Jetbrains will give you a free license for IntelliJ just by telling them what ASF projects you work on - ;-)

Ralph


On Sep 27, 2012, at 2:20 PM, Gary Gregory wrote:

> There are three cases: static, final static, and instance. 
> 
> Usually they each get a visual cue in plain text as Static, FINAL_STATIC and instance. 
> 
> Gary
> 
> On Sep 27, 2012, at 16:02, Paul Benedict <pb...@apache.org> wrote:
> 
>> I think Ralph is right. You are either doing UPPERCASE for constants or camelCase for non-constant values.
>> 
>> Paul
>> 
>> On Thu, Sep 27, 2012 at 2:51 PM, Ralph Goers <ra...@dslextreme.com> wrote:
>> For variable naming I have followed the default checkstyle rules.  To be honest, I can't recall seeing a variable before where the first letter was capitalized and the rest of it wasn't.  I'd have to look at the Sun naming guidelines or other references such as effective Java to see if that is a recommended practice.
>> 
>> Ralph
>> 
>> 
>> 
>> 
>> On Sep 27, 2012, at 10:52 AM, Gary Gregory wrote:
>> 
>>> In v2 trunk, I see decls like:
>>> 
>>> private static LoggerContextFactory factory;
>>> 
>>> Which in my world should be:
>>> 
>>> private static LoggerContextFactory Factory;
>>> 
>>> As it is, it may not be possible to tell a static from an instance variable (unless the ivar is prefixed with "this.")
>>> 
>>> For example, it is not possible with org.apache.logging.log4j.AbstractLoggerTest.currentEvent
>>> 
>>> This makes groking the code harder.
>>> 
>>> Thoughts?
>>> 
>>> Gary
>>> 
>>> -- 
>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org 
>>> JUnit in Action, 2nd Ed: http://bit.ly/ECvg0
>>> Spring Batch in Action: http://bit.ly/bqpbCK
>>> Blog: http://garygregory.wordpress.com 
>>> Home: http://garygregory.com/
>>> Tweet! http://twitter.com/GaryGregory
>> 
>> 


Re: Static var name style

Posted by Gary Gregory <ga...@gmail.com>.
There are three cases: static, final static, and instance.

Usually they each get a visual cue in plain text as Static, FINAL_STATIC
and instance.

Gary

On Sep 27, 2012, at 16:02, Paul Benedict <pb...@apache.org> wrote:

I think Ralph is right. You are either doing UPPERCASE for constants or
camelCase for non-constant values.

Paul

On Thu, Sep 27, 2012 at 2:51 PM, Ralph Goers <ra...@dslextreme.com>wrote:

> For variable naming I have followed the default checkstyle rules.  To be
> honest, I can't recall seeing a variable before where the first letter was
> capitalized and the rest of it wasn't.  I'd have to look at the Sun naming
> guidelines or other references such as effective Java to see if that is a
> recommended practice.
>
> Ralph
>
>
>
>
> On Sep 27, 2012, at 10:52 AM, Gary Gregory wrote:
>
> In v2 trunk, I see decls like:
>
> private static LoggerContextFactory factory;
>
> Which in my world should be:
>
> private static LoggerContextFactory Factory;
>
> As it is, it may not be possible to tell a static from an instance
> variable (unless the ivar is prefixed with "this.")
>
> For example, it is not possible with
> org.apache.logging.log4j.AbstractLoggerTest.currentEvent
>
> This makes groking the code harder.
>
> Thoughts?
>
> Gary
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> JUnit in Action, 2nd Ed: <http://goog_1249600977/>http://bit.ly/ECvg0
> Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>
>
>

Re: Static var name style

Posted by Ralph Goers <ra...@dslextreme.com>.
Actually,  the static variables are bold italic. Class member variables are bold. local variables are normal. I'm pretty sure that behavior can be configured.

Ralph

On Sep 27, 2012, at 1:14 PM, Ralph Goers wrote:

> Does Eclipse not do highlighting?  This is what I see in IntelliJ. Note that the static variables are bolded and local variables are not. 
> 
> 
> <PastedGraphic-1.png>
> 
> 
> Ralph
> 
> On Sep 27, 2012, at 1:02 PM, Paul Benedict wrote:
> 
>> I think Ralph is right. You are either doing UPPERCASE for constants or camelCase for non-constant values.
>> 
>> Paul
>> 
>> On Thu, Sep 27, 2012 at 2:51 PM, Ralph Goers <ra...@dslextreme.com> wrote:
>> For variable naming I have followed the default checkstyle rules.  To be honest, I can't recall seeing a variable before where the first letter was capitalized and the rest of it wasn't.  I'd have to look at the Sun naming guidelines or other references such as effective Java to see if that is a recommended practice.
>> 
>> Ralph
>> 
>> 
>> 
>> 
>> On Sep 27, 2012, at 10:52 AM, Gary Gregory wrote:
>> 
>>> In v2 trunk, I see decls like:
>>> 
>>> private static LoggerContextFactory factory;
>>> 
>>> Which in my world should be:
>>> 
>>> private static LoggerContextFactory Factory;
>>> 
>>> As it is, it may not be possible to tell a static from an instance variable (unless the ivar is prefixed with "this.")
>>> 
>>> For example, it is not possible with org.apache.logging.log4j.AbstractLoggerTest.currentEvent
>>> 
>>> This makes groking the code harder.
>>> 
>>> Thoughts?
>>> 
>>> Gary
>>> 
>>> -- 
>>> E-Mail: garydgregory@gmail.com | ggregory@apache.org 
>>> JUnit in Action, 2nd Ed: http://bit.ly/ECvg0
>>> Spring Batch in Action: http://bit.ly/bqpbCK
>>> Blog: http://garygregory.wordpress.com 
>>> Home: http://garygregory.com/
>>> Tweet! http://twitter.com/GaryGregory
>> 
>> 
> 


Re: Static var name style

Posted by Ralph Goers <ra...@dslextreme.com>.
Does Eclipse not do highlighting?  This is what I see in IntelliJ. Note that the static variables are bolded and local variables are not. 





Ralph

On Sep 27, 2012, at 1:02 PM, Paul Benedict wrote:

> I think Ralph is right. You are either doing UPPERCASE for constants or camelCase for non-constant values.
> 
> Paul
> 
> On Thu, Sep 27, 2012 at 2:51 PM, Ralph Goers <ra...@dslextreme.com> wrote:
> For variable naming I have followed the default checkstyle rules.  To be honest, I can't recall seeing a variable before where the first letter was capitalized and the rest of it wasn't.  I'd have to look at the Sun naming guidelines or other references such as effective Java to see if that is a recommended practice.
> 
> Ralph
> 
> 
> 
> 
> On Sep 27, 2012, at 10:52 AM, Gary Gregory wrote:
> 
>> In v2 trunk, I see decls like:
>> 
>> private static LoggerContextFactory factory;
>> 
>> Which in my world should be:
>> 
>> private static LoggerContextFactory Factory;
>> 
>> As it is, it may not be possible to tell a static from an instance variable (unless the ivar is prefixed with "this.")
>> 
>> For example, it is not possible with org.apache.logging.log4j.AbstractLoggerTest.currentEvent
>> 
>> This makes groking the code harder.
>> 
>> Thoughts?
>> 
>> Gary
>> 
>> -- 
>> E-Mail: garydgregory@gmail.com | ggregory@apache.org 
>> JUnit in Action, 2nd Ed: http://bit.ly/ECvg0
>> Spring Batch in Action: http://bit.ly/bqpbCK
>> Blog: http://garygregory.wordpress.com 
>> Home: http://garygregory.com/
>> Tweet! http://twitter.com/GaryGregory
> 
> 


Re: Static var name style

Posted by Paul Benedict <pb...@apache.org>.
I think Ralph is right. You are either doing UPPERCASE for constants or
camelCase for non-constant values.

Paul

On Thu, Sep 27, 2012 at 2:51 PM, Ralph Goers <ra...@dslextreme.com>wrote:

> For variable naming I have followed the default checkstyle rules.  To be
> honest, I can't recall seeing a variable before where the first letter was
> capitalized and the rest of it wasn't.  I'd have to look at the Sun naming
> guidelines or other references such as effective Java to see if that is a
> recommended practice.
>
> Ralph
>
>
>
>
> On Sep 27, 2012, at 10:52 AM, Gary Gregory wrote:
>
> In v2 trunk, I see decls like:
>
> private static LoggerContextFactory factory;
>
> Which in my world should be:
>
> private static LoggerContextFactory Factory;
>
> As it is, it may not be possible to tell a static from an instance
> variable (unless the ivar is prefixed with "this.")
>
> For example, it is not possible with
> org.apache.logging.log4j.AbstractLoggerTest.currentEvent
>
> This makes groking the code harder.
>
> Thoughts?
>
> Gary
>
> --
> E-Mail: garydgregory@gmail.com | ggregory@apache.org
> JUnit in Action, 2nd Ed: <http://goog_1249600977/>http://bit.ly/ECvg0
> Spring Batch in Action: <http://s.apache.org/HOq>http://bit.ly/bqpbCK
> Blog: http://garygregory.wordpress.com
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory
>
>
>

Re: Static var name style

Posted by Ralph Goers <ra...@dslextreme.com>.
For variable naming I have followed the default checkstyle rules.  To be honest, I can't recall seeing a variable before where the first letter was capitalized and the rest of it wasn't.  I'd have to look at the Sun naming guidelines or other references such as effective Java to see if that is a recommended practice.

Ralph




On Sep 27, 2012, at 10:52 AM, Gary Gregory wrote:

> In v2 trunk, I see decls like:
> 
> private static LoggerContextFactory factory;
> 
> Which in my world should be:
> 
> private static LoggerContextFactory Factory;
> 
> As it is, it may not be possible to tell a static from an instance variable (unless the ivar is prefixed with "this.")
> 
> For example, it is not possible with org.apache.logging.log4j.AbstractLoggerTest.currentEvent
> 
> This makes groking the code harder.
> 
> Thoughts?
> 
> Gary
> 
> -- 
> E-Mail: garydgregory@gmail.com | ggregory@apache.org 
> JUnit in Action, 2nd Ed: http://bit.ly/ECvg0
> Spring Batch in Action: http://bit.ly/bqpbCK
> Blog: http://garygregory.wordpress.com 
> Home: http://garygregory.com/
> Tweet! http://twitter.com/GaryGregory