Developer Skill Sprint: Refactoring Legacy Code to Design Patterns

Posted by on in Programming

Developer Skill Sprint: Refactoring Legacy Code to Design Patterns

Daniele Teti -

Tuesday, March 22, 2016


Skill Sprint Replay on Embarcadero YouTube channel:


Refactoring Introduction

Refactoring is a controlled technique for improving the design of an existing code base

  • Simplify debug
  • Lower code maintenance cost
  • Higher ROI (Return on Investment)
  • Lower TCO (Total Cost of Ownership)
  • Keep developers happy

Design Patterns Introduction

Explains a general design that addresses a recurring design problem in object-oriented systems

  • Improve developers discussions
  • shared vocabulary
  • Speed up the learning process for new team members
  • Allow to learn from the others experience
  • Simplify debug

Refactoring: The Book

  • by Martin Fowler, Don Roberts, William Opdyke, Kent Beck, John Brant
  • Publisher: Addison-Wesley Professional
  • Release Date: June 1999
  • Introduce the refactoring process
  • The bulk of the book is around seventy refactorings described in detail
  • Several development environments, Delphi included, automate many of the refactorings described in this book. 
  • Refactoring has become a full-fledged part of the software development lexicon

Design Patterns: The Book

  • by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides
  • Publisher: Addison-Wesley Professional
  • Release Date: October 31, 1994
  • Introduces the concept of Design Patterns as reusable elements
  • Covers the design of object-oriented software
  • How to investigate requirements, create solutions and then translate designs into code
  • Shows developers how to make practical use of the most significant recent developments
  • A summary of UML notation is included

Refactoring to Patterns: The Book

  • By Joshua Kerievsky
  • Publisher: Addison-Wesley Professional
  • Release Date: August 15, 2004
  • Refactoring to Patterns is the marriage of refactoring with patterns.
  • Suggests that using patterns to improve an existing design is better than using patterns early in a new design.
  • This is true whether code is years old or minutes old.

Some Important Code Refactoring Patterns

Refactoring to Patterns

  • Chain Constructors
  • Replace Multiple Constructors with Factory Methods
  • Encapsulate Subclasses with Factory Methods
  • Form Creation Class
  • Encapsulate Composite with Builder
  • Compose Method
  • Many others

Learning Resources

Previous CodeRage session on Maintainable Code - Separating Logic from UI 
Video not found or Youtube service not available


Gold User, Rank: 15, Points: 256
This latest season of Developer Skill Sprints focuses on programming tips and techniques most requested by attendees of the past 72 skill sprints we’ve already presented. This quarter we’ll take your