Skip to content

Working with Legacy Code

Contents:

Porting Legacy Code

Understanding the Legacy Code Context

When incorporating legacy code into our current projects, it's crucial to acknowledge the limitations and challenges posed by the original development context. Often, this code was not crafted with rigorout unit testing standards in mind. Due to tight schedules and resource constraints, refactoring the entire legacy codebase may not be feasible.

Unit Testing Expectations for Legacy Code

  • Scope of Testing: For legacy code, our unit tests will primarily focus on testable functions. It's important to understand that these test suites may not be comprehensive or exhaustive. This limitation arises from legacy functions' original code structure, which may not have been optimized for detailed unit testing.
  • NOTE for Developers: When porting Classes/Components/Services from legacy code, developers are expected to include the following note:
...
// NOTE: THIS CLASS / COMPONENT / SERVICE WAS PORTED FROM A LEGACY PROJECT, AND
// WAS NOT WRITTEN WITH UNIT TESTS IN MIND. THEREFORE, WE HAVE MINIMALLY
// WRITTEN UNIT TESTS TO COVER BROAD FUNCTIONS THEREIN. THESE ARE NOT
// EXHAUSTIVE, HOWEVER, AS THIS CODE WAS NOT ORIGINALLY WRITTEN IN A MANNER
// CONDUCIVE TO PROPER UNIT TESTING.
...

Where to place the note

It is expected this note will be placed in the header of the file, above the class declaration and below the import statements.