Scaling Up
One of the bigger challenges in taming legacy code is the size and scope of the existing functions. Larger functions have more dependencies and more complicated logic. You first need to write characterization tests to capture the intent before refactoring to smaller, more focused functions. The functions that I deferred so far fall in that category. I had run out of simple functions and needed to forge ahead.
The next most complicated functions were the date and time parsing utility functions deferred earlier. Of the two remaining functions, splitDateTime() and parseDateInternal(), splitDateTime() was the easier. For one, parseDateInternal() calls splitDateTime(), and it also calls other functions of the datepicker, both original ...
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