Real-World Refactoring
The examples you’ve seen in this chapter may give you the confidence to refactor your own code in the applications you’re working on. Code that we have to deal with in the real world, unfortunately, rarely appears as an amiable candidate for refactoring. The journey to refactor the code can be daunting and, at times, dissuading. The frustrations may lead us to feel hopeless and tempt us to throw in the towel. But remember that it doesn’t have to be an all-or-nothing effort.
Big-bang refactoring may result in a big-bang failure. Instead, refactor incrementally. You can start by converting imperative loops into functional iterations using internal iterators like Stream, IntStream, and so on. The if conditions may be refactored ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access