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

cleanup euids #35

Merged
merged 5 commits into from
Aug 10, 2023
Merged

cleanup euids #35

merged 5 commits into from
Aug 10, 2023

Conversation

andrewmwells-amazon
Copy link
Contributor

Issue #, if available:

Description of changes:
Cleanup code from #33 Change Entities to always store the EUID as a JsonEUID object instead of sometimes storing this and sometimes a String representation. Make the same change for Entities.parents.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link
Contributor

@john-h-kastner-aws john-h-kastner-aws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I have quite enough context to understand this change, but it looks alright to me.

Copy link
Contributor

@khieta khieta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, but two general comments:

  • Inconsistent use of EUID vs. Euid. Not sure which is correct according to Java naming conventions.
  • Would it make sense to change toCedar to toString? I think this would make it a little more obvious what the code is doing. Also: why are there different implementations for toCedar and toString? When would you want User::alice instead of User::"alice"?

Comment on lines 46 to 48
actionEuid = "Action::\"" + actionId + "\"";
if (!e.getEuid().toCedar().equals(actionEuid)) {
e.parentsEUIDs.add(new JsonEUID(actionType, actionId));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it would be a little cleaner to test equality of e and the action type without converting to a string. So save new JsonEUID(actionType, actionId) to some variable uid and then check!e.getEuid().equals(uid)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't use the default equals method here and if I define equals SpotBugs says I should also define hashCode. Since I don't want to do that and string equality is exactly what we want, I think I'll leave as-is. I did rename toCedar -> toString and removed the old toString though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. What about the EUID vs. Euid issue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's change that in a separate PR since it will touch a bunch of files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found https://stackoverflow.com/questions/15526107/acronyms-in-camelcase which gives various options. I personally found this answer (https://stackoverflow.com/a/45440841) most reasonable. Unfortunately, it violates Jackson's naming convention (JavaScript Object Notation could be argued to go to JSON or JsON but not Json). It would also indicate Entity Unique Identifier should go to EUId which 1) looks weird to me and 2) doesn't match our docs.

I put up (#42) with some obvious consistency changes, but I'm not convinced which style is best for us, so it's only Euid -> EUID

@khieta
Copy link
Contributor

khieta commented Aug 10, 2023

Heads up: I just merged #39 , which may cause conflicts with this PR

@andrewmwells-amazon andrewmwells-amazon merged commit 2c58b9b into main Aug 10, 2023
@andrewmwells-amazon andrewmwells-amazon deleted the andrewmwells/cleanup_euids branch August 10, 2023 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants