8.2 Legacy Code
Legacy code challenges tend to induce the strong motivator of fear into even the most senior developers. Consider having to specialize a small part of a longer, untested function. Imagine that getting your feature implemented is a matter of introducing three lines worth of variant behavior in the midst of thirty lines. As an experienced programmer, you know that the right design would involve factoring common behavior to a common place. The template method design pattern represents one acceptable solution.
(Another solution would involve introducing a conditional. But that’s often a recipe for gradual decay, as functions become weighted down with flags and nested blocks.)
Yet, also from the stance of experience, many programmers ...
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