Another Adapter Example
Here is a class that was introduced in Legacy Refactoring:
Here is a class that was introduced in Legacy Refactoring:
Developing clean, testable, code has been a passion since my first full-time job as a programmer, when I inherited a mess of spaghetti-code in the form of a large ASP classic web application. Since 2009 I've written written more than a dozen blog posts on unit testing, created several presentations, and evangelized unit testing at every opportunity.
Any code that has been released is "legacy code." This article is about that really old legacy code your team inherited (from itself?). It wasn't designed in a way that is amenable to unit testing, and yet you're on a mission to add features, stamp out bugs, and improve the quality through refactoring. Here are some brief, practical tips for getting through this Gordian knot without a scimitar.
Each team will want to find its own style for expressing unit tests. Or multiple styles, depending on the situation. The patterns below represent just a handful of techniques that may be useful in creating easy-to-read and easy-to-maintain unit tests.
Books and a few relevant articles that influenced the techniques found in this web site.
S.O.L.I.D. (henceforth "SOLID") is a set of object-oriented design principals, assembled by Robert C. Martin and popularized in many of his articles and books. The following table is from his article The Principles of OOD:
Thinking Like QA
Unfinished work-in-progress