Refactoring #2 clean up time - BBK-PiJ-2014-66/cw4 GitHub Wiki
Sunday 15 March 2015
- Looking at to be marked version 2.0.0 the handling of time is muddled
- In
ContactManagerPlusinterface have added methods: - Thursday 19 March: carry on ...
- These two methods are about JUnit testing and should not be exposed in the Interface for normal use.
- The implementation
ContactManagerImplhas a class variable Calendar pretendNow. This is particularly problematic as Serialization is used to store the state for run to run. So thispretendNowvariable is currently included in the state. Not a good idea there is no need for it to be stored. So need to get rid ofpretendNowas a class variable. ContactManagerImplhas methods:- public setPretendNow from interface
ContactManagerPlus - public getPretendNow from interface
ContactManagerPlus - private checkDateIsFuture(date)
- In addition have Uninstantiable class CalendarUtils with a single static method:
- public static boolean sameDate(Calendar,Calendar)
Conclusion
- have Calendar/Date stuff mixed into ContactManager and getting into the save-state-file
- should separate it out into a package of its own.
- Q: what to call it?
timetoolsseems a nice name. But need to think about package namespace issue? See Refactoring #3 package namespace, api version and since - The time offset stuff could usefully go into a singleton object using the enum syntax as this comes up
with nicely readable code call it
NowOrPretendwith a single instanceTIME