Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ProtectedProperty to immutable for preserving immutablility on any execution context #2

Closed
FrancescoJo opened this issue Mar 18, 2022 · 0 comments
Assignees
Labels
breaking Involves a breaking change enhancement New feature or request

Comments

@FrancescoJo
Copy link
Collaborator

FrancescoJo commented Mar 18, 2022

AS-IS

class com.sirloin.jvmlib.util.ProtectedProperty<T>(
    var value: T,
    // ...
)

TO-BE

class com.sirloin.jvmlib.util.ProtectedProperty<T>(
    val value: T,
    // ...
)

MOTIVATION

Even if we declared value as val, immutablility will be broken if the target is mutable. Assigning final mutable collections or an arbitary object which holds some mutable fields, for example.

The current ProtectedProperty#value declared as var is a meaningless attempt - even worse, it breaks the immutability of the client code.

Therefore, change value to val so that mutability management can be left to the client code.

IMPACT

ProtectedProperty value changing codes will not compile after this fix.

@FrancescoJo FrancescoJo added enhancement New feature or request breaking Involves a breaking change labels Mar 18, 2022
@FrancescoJo FrancescoJo self-assigned this Mar 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Involves a breaking change enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant