-
Notifications
You must be signed in to change notification settings - Fork 249
Mutable objects used for immutable values #772 #1596
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
base: main
Are you sure you want to change the base?
Mutable objects used for immutable values #772 #1596
Conversation
I like the removal of all the setters! |
I agree with Robert. I think this PR does not fully embrace the immutable pattern.
It would be good to explore the immutables library to address some of these points. Note that this PR contains a removal of some utility copy-constructors ( |
+1 to PolarisImmutables |
From the bug description I thought the point was to make those object not mutable, i didn't think there was a library already there hence why I created the builders. can you guys point me in the right direction thx ? @singhpk234 |
@fabio-rizzo-01 I think the ask is that you use this interface. Besides this, I think we should try to minimize the changes that callers need to make as much as possible. |
Looking at that interface and seeing where it is used, it seems to me that using it would require even more changes that what I already did. Taking PolarisEntityCore as an example, to convert that to an immutable object I'd have to create an interface (something like PolarisEntityCoreInt) that uses PolarisImmutable annotation, that would generate a class called Immutable PolarisEntityCoreInt. So all the code that is using PolarisEntityCore object it needs to be updated to use the new immutable object. Is this what you guys are suggesting ? @snazy @singhpk234 |
Yes. |
Ok. In doing so every entity object in Polaris will need to change because every entity (catalog, namespace, etc.) extends PolarisEntity that extends PolarisBaseEntity. Correct? |
@fabio-rizzo-01 the example you gave is a good one; my point is you could reduce that change to only this line:
Which could become like:
(Or we could make |
that makes sense, I'll wait for the others to answer my previous question before I'll make the changes. |
Thanks @fabio-rizzo-01 for doing this! +1 on using annotation |
34c28d8
to
2a491c8
Compare
…base and core fields
a1751af
to
f620b0d
Compare
I understand the push to use PolarisImmutable, but I've identified some issues with its implementation: Our object hierarchy consists of Core -> Base -> Entity -> Catalog, with each class extending the previous one. Applying PolarisImmutable to Core and Base would result in two new immutable classes, both of which are final. This prevents further extension of the immutable Base class, disrupting our current hierarchy. While there are workarounds, they would necessitate significant code changes, which I believe should be minimized in this part of the repository. |
Updated Polaris entity objects to use builders instead of normal constructors and removed all the set methods to guarantee object immutability.
All the other changes are refactoring based on those changes.