-
-
Notifications
You must be signed in to change notification settings - Fork 100
Remove ArrayUtilities and replace with Java built-ins #876
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: array-utilities
Are you sure you want to change the base?
Remove ArrayUtilities and replace with Java built-ins #876
Conversation
litiengine/src/main/java/de/gurkenlabs/litiengine/physics/PhysicsEngine.java
Outdated
Show resolved
Hide resolved
…in Java methods. Resolves gurkenlabs#863
eb89118
to
c9d8056
Compare
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 see the rationale behind cleaning up redundancy and relying more on java’s built-in features like streams. That said, I’d like to share a major concern I have with this... Removing these utility methods might improve conciseness in some areas but at the cost of reusability and maintainability.
For example, as @nightm4re94 stated in #863, something like Arrays.stream(arr).collect(Collectors.joining(separator))
is technically a one-liner,.. but if it’s used in multiple places, we’re effectively re-implementing the same logic over and over. A single utility method (like ArrayUtilities.join) gives you:
- A central place to evolve or fix behavior (e.g., null safety, trimming, edge case handling, etc),
- A clearer, intention revealing API at the call site, (It's not immediately clear what
Arrays.stream(arr).collect(Collectors.joining(separator))
is doing.ArrayUtilities.join
, however, is very clear.) - Less repetition across the codebase.
I understand and support simplifying where appropriate, but I think think removing these helper methods would has the opposite effect.
Additionally, ArrayUtilities is public api, downstream components (games using the engine) may be relying on it directly. If it's going to be removed entirely, then it should probably be deprecated for removal first.
I think the key issue is that these are so many places where a list or array of objects are being converted to a comma separated string and back. I would think it would strictly be for de/serailization of data. |
Thanks @Gamebuster19901 for chiming in - I think there are truths on both sides that we can build a compromise from:
|
Removed ArrayUtilities, ArrayUtilitiesTests, and replaced with built-in Java methods.
Resolves Issue 863