commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sebb (JIRA)" <>
Subject [jira] [Commented] (CRYPTO-30) Mutable fields should be private
Date Wed, 27 Apr 2016 08:37:13 GMT


Sebb commented on CRYPTO-30:

The getters should be protected, as the fields were protected.

The getters/setters should not be provided unless they are actually needed *now*.
Don't add them 'just in case' as that makes it much harder to change the implementation later.

> Mutable fields should be private
> --------------------------------
>                 Key: CRYPTO-30
>                 URL:
>             Project: Commons Crypto
>          Issue Type: Bug
>            Reporter: Sebb
>            Assignee: Ferdinand Xu
> Mutable fields should be private or possibly package-protected, never protected or public.
> Once a field is published, it's impossible to ensure that it is properly synchronised,
and it is impossible to change the implementation without API breakage.
> Only constants should be published.
> If there is really a need to access the field externally, this should be done through
getters/setters, as those allow synchronisation to be added and make it easier to change the
> Also, it's easy to add a getter/setter later if access is found to be needed.
> Don't add one 'just in case' because it cannot easily be removed.
> This observation applies to:
> StreamOutput.out
> CTRCipherInputStream.streamOffset
> CTRCipherOutputStream.streamOffset
> CipherInputStream - lots of protected mutable state
> CipherOutputStream - ditto

This message was sent by Atlassian JIRA

View raw message