You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Ferdinand Xu (JIRA)" <ji...@apache.org> on 2016/04/27 08:55:12 UTC
[jira] [Commented] (CRYPTO-30) Mutable fields should be private
[ https://issues.apache.org/jira/browse/CRYPTO-30?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15259657#comment-15259657 ]
Ferdinand Xu commented on CRYPTO-30:
------------------------------------
[~sebb@apache.org] Thank you for raising this up. I have made all of the variables as package private or private and provided Getter/Setter as protected. By this way, users are able to extend the existing crypto input/output stream.
PR was created at https://github.com/apache/commons-crypto/pull/19. Please help me review it. Thank you!
> Mutable fields should be private
> --------------------------------
>
> Key: CRYPTO-30
> URL: https://issues.apache.org/jira/browse/CRYPTO-30
> 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 implementation.
> 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
(v6.3.4#6332)