Select Page


Refactoring, Automated Unit Testing, and TDD: Making Existing Code Easier to Understand, Maintain, and Change

My refactoring, automated unit testing, and TDD coaching and tutorials reflect extensive efforts to learn from respected software architects/developers who practice primarily in the lean-agile process space, via their books, on-line blogs, conference presentations, direct collaboration, local and global user groups, combined with my personal “hands-on” experience as a software architect/developer on teams using refactoring, automated unit testing, and TDD on production software and meeting business delivery targets.

My experience includes coming into environments where no formal refactoring patterns, automated unit testing, and TDD were used previously, helping to develop custom training and present it to internal teams, introducing key code qualities and practices, and teaching the basics of these tools to increase quality and reduce development lead times. It also includes extensive experience providing “hands-on” coaching, side-by-side or in pairing fashion, as in “internal embedded coach.”

The outline below provides a general scope of the topics that could be covered to introduce your teams to refactoring, automated unit testing, and TDD (test-driven development). It represents a core of topics that would be customized after gathering more information specific to your context as well as considering the type of coaching or tutorials desired (ex. given as a single-day or multi-day classroom style workshop, or as several 2-4 hour workshops over several weeks as part of a fixed period embedded coaching engagement.

  1. What Is Refactoring?
  2. What is Unit Testing?
    • Automated unit testing – your safety net
    • What a unit test is, what it isn’t
    • F.I.R.S.T.
    • Unit testing frameworks
    • Setup a xUnit environment if needed
  3. What is Test-Driven Development?
    • Test-first or test-driven?
    • Feed-back loops and double-loop learning
    • The TDD loop (test-first programming)
    • It’s more than testing
    • Why it’s still test-driven design to me
    • Stubs, fakes, and mocks
    • State-based and behavior-based testing
    • Hands-on example TDD exercise
    • Good tests
    • Three laws of TDD
  4. Code Smells – The Common Ones
    • Tightly coupled
    • Weakly cohesive
    • Redundant
    • There are more
  5. Refactoring Patterns – The Common Ones
  6. Programming by Intention and Intention Revealing Code
    • Partition code by level of abstraction (separation of concerns)
    • Private methods
    • Sargent method
    • Reading code top-down
    • Meaningful names
    • Implementation patterns
  7. Refactoring When You Don’t Have Unit Tests
    • What is legacy code?
    • Legacy code change algorithm
    • Sensing and separation
    • Seams
    • Dependency-breaking techniques (three to start with)
  8. Practice, Practice, Practice
  9. Other Topics to Discuss
    • It runs on my pc
    • Continuous integration
    • It is not all about the tools
    • How much code coverage?
    • Emergent design complementary tools