Open teo-tsirpanis opened 3 years ago
Curious. ColonizationSaveGameReader is a rarely used standalone class. Refactoring it has very limited benefit. I have to ask why did you bother?
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.
This PR refactors the
ColonizationSaveGameReader
class by using static methods instead of creating objects only to call one method on them namedprint
orrun
. 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 thegetString
method by using another overload of Java'sString
class' constructor. Speaking ofgetString
, it was moved to an inner class namedUtilities
to avoid a cyclic dependency warning by Designite.