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

Refactor and optimize the ColonizationSaveGameReader class. #97

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

teo-tsirpanis
Copy link

This PR refactors the ColonizationSaveGameReader class by using static methods instead of creating objects only to call one method on them named print or run.
Besides the reduced temporary object allocations, this PR also eliminated a redundant copy of the entire save file at the class' now-deleted constructor, and an array copy at the getString method by using another overload of Java's String class' constructor.
Speaking of getString, it was moved to an inner class named Utilities to avoid a cyclic dependency warning by Designite.

Allocations and lines of code were reduced.
It eliminates a cyclic dependency design smell reported by Designite.
@mpope042
Copy link
Member

mpope042 commented Jun 8, 2021

Curious. ColonizationSaveGameReader is a rarely used standalone class. Refactoring it has very limited benefit. I have to ask why did you bother?

@teo-tsirpanis
Copy link
Author

teo-tsirpanis commented Jun 8, 2021

It is for a "Software Quality" university project. We had to pick a project and apply refactorings to it to increase its quality and my team chose FreeCol. And I personally enjoy refactoring and optimizing code.

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.

2 participants