#126 Add (explicit) access level modifiers to all fields/methods


I wasn't sure if this was a bug or a request, but thought it might be more polite as a request :)

Many fields and some methods in the CDK have no access modifier (public, private, protected) and so they default to 'package'. I don't think that I have ever seen an explicit use of the 'package' modifier in java code that was not an example. Therefore, it seems reasonable to assume that some other level is actually desired.

Although it may seem trivial, explicit access modifiers can help weed out unused members in a class. If a member is private, but never read, then static code analysis tools will pick it up as potentially unused. Also, if a member is implicitly package, and is then made private, it may result in a compile error where some other class in the same package was using it as if it was public.

Indeed, there may even be rare examples of methods or members that are meant to be package-level access; in which case, they should definitely be explicitly marked as such, since this is a minimal level of documentation in a way. Then a comment as to exactly why this is could be added! :)


Log in to post a comment.