Refactoring of UglyTrivia Java legacy code step by step