Naming convention: Final fields (not static)

Posted by Zeeker on Programmers See other posts from Programmers or by Zeeker
Published on 2014-08-04T14:12:20Z Indexed on 2014/08/23 10:34 UTC
Read the original article Hit count: 257

Filed under:
|
|

Today I had a discussion with a co-worker about the naming of final fields in Java classes.

In his opionion final fields should also be considered constants since their values won't change after the creation of the instance.

This would lead to the following naming convention for final fields:

public class Foo {
    private static final String BLA_BLA = "bla";

    private final String BAR_BATZ;

    ...
}

In my opinion only static final fields should be considered constants while fields which are only final should follow the usual camelCase naming convention.

public class Foo {
    private static final String BLA = "bla";

    private final String barBatz;

    ...
}

Now I'm a bit uncertain since he is a far more experienced programmer than I am and I usually agree with his opinions and consider him a very good developer.

Any input on this?

© Programmers or respective owner

Related posts about java

Related posts about naming