-
Notifications
You must be signed in to change notification settings - Fork 23
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
removed upper and lower for name #77
removed upper and lower for name #77
Conversation
1f011a0
to
8abf1e0
Compare
gestalt-module/src/main/java/org/terasology/gestalt/naming/Name.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know whether removing/deprecating toLowerCase and toUpperCase is strictly necessary, but it will likely reduce misuse for later string comparison...
@immortius do you have any opinion on this? And what is the process of merging a change in gestalt and porting it back to v5?
gestalt-module/src/main/java/org/terasology/gestalt/naming/Name.java
Outdated
Show resolved
Hide resolved
gestalt-module/src/main/java/org/terasology/gestalt/naming/Name.java
Outdated
Show resolved
Hide resolved
…e.java Co-Authored-By: Tobias Nett <[email protected]>
…e.java Co-Authored-By: Tobias Nett <[email protected]>
…e.java Co-Authored-By: Tobias Nett <[email protected]>
Mmmm. I'm not against removing (or deprecating) the toUpper and toLower methods, but I think we should leave toString alone - toString exists for display, introducing a new function for this isn't necessary. Also don't think it is worth changing the spelling of normalised to a perhaps slightly more correct spelling when it is only used internally. |
my main reasoning would be that toString should return the id of the object and that choosing to display it would be a more deliberate process. we probably do more comparisons using toString vs cases where we would display the name of the object. The default behavior would be to give back the normalized version because in most cases it would be used for a comparison right? |
I have to agree with both of you (to some degree). However, I also agree with @pollend that it is a bit of bad design if it is too easy to use the class in a wrong way... I'm wondering whether something like |
We could also add Name::compareTo(String) if that would be more straight forwards. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While at it - would it make sense to add contains(substring)
and startsWith(prefix)
/endsWith(suffix)
? Would that be a bad idea as it would weaken the Name as a unit?
gestalt-module/src/main/java/org/terasology/gestalt/naming/Name.java
Outdated
Show resolved
Hide resolved
@@ -39,62 +39,81 @@ | |||
*/ | |||
public static final Name EMPTY = new Name(""); | |||
|
|||
private final String normalised; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's keep it as it was - less noise in the diff.
private final String normalised; | |
private final String normalisedName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cheers, I'm happy with this outcome.
This issue for terasology shows kind of a key problem with transforming the name of the asset in gestalt. MovingBlocks/Terasology#3887 I think we should avoid transforming the name at all and just use the name that was provided by the asset. Any kind of additional transformation on the type seems like a good way to introducing bugs. for one case it might be uppercase but another case it could be lower. When systems intersect is where we will see kind of a mix of the two and working out if its one or the other seems like a major problem.