Hi Marko,
Sorry for delay, i will reply to your during that week.
Thanks.
Roman Ivanov
On 09 Jul 2015, at 05:07, Roman Ivanov <romani...@gmail.com> wrote:> I cannot understand the rationale behind allowing public final fields only in final classes. What is the difference if the class is not final? The field canot be overridden.Agree, but that is just additional security for case described there - https://github.com/checkstyle/checkstyle/issues/61#issuecomment-109317543
> I often expose final fields from my class without burdening the design with extra getters and I don't see any potential for harm.Agree to some extend, and we try to make it possible by option, and let user decide what he need to check.
Rationale: Forcing all fields of class to have private modified by default is good in most cases, but in some cases it drawbacks in too much boilerplate get/set code. One of such cases are immutable classes.
Restriction: Check doesn't check if class is immutable, there's no checking if accessory methods are missing and all fields are immutable, we only check if current field is immutable and defined in final class
> In conclusion, a class should either be allowed or disallowed to declare public fields---whether final or not.You are absolutely right ! So you have option to use that Check or not.Checkstyle is tool set and you cherry pick individual tools you need or want or care about. You adjust tools to your needs (defaults values might not work well and should be changed to match reality of your project).
Hi Marko,sorry for delay.thanks a lot for example , it helped.Looks like reason of misunderstanding it a Check functionality - it try to check too much. Our bad design.Example that you provided is valid to some extend. It is matter of style: to have public final fields or wrap them with get/set .So, I propose to have new property "allowPublicFinal"="false/true" ("false" is default.).That will reconcile two groups of engineers on how to manage access to fields.
Please confirm that this will resolve your problem and create issue against us on github - https://github.com/checkstyle/checkstyle/issues .