Again, a chapter on cleaning up a Java class. This time JCommon
org.jfree.date
Some examples of improvements:
- Replacing multiple related constants with an enum
- changing names for clarification
- one example was to change date.addDays() to date.plusDays()
to imply that the function does not modify the date object
but instead returns a new date with the addition of days sent to plusDays
(think like immutable strings in Java)
- Moving code apart from unrelated areas to related areas (e.g. a new
or existing class)
- Example - a search for use of a group of variables shows they
are only used in one derivative class - then move them to that class!
- Adding a factory class to generate instances with specific constraints/
details
- deleting redundant comments
- adding "explaining temporary variables" to complicated algorithms
for clarity
- replacing magic numbers with explanatory variables
bj
2019-09-22