Refactoring C++ legacy code through pure functions

Talk
Mon TBD - 00:45
You don't need a laptop
Atlas 2 Room
C/C++

Summary

Refactoring legacy code is an inherently difficult problem. Safe refactoring requires tests, but writing tests on code that doesn’t have them requires safe changes to the code. To solve this dilemma, I’ve been using the techniques described by Michael Feathers in his amazing book “Working Effectively With Legacy Code”.

 

I believe now that I found another technique that takes advantage of pure functions and functional programming, a technique made even more interesting by the introduction of lambdas in C++. The technique consists of three steps:

  1. safe refactorings towards pure functions
  2. data-driven and property-based tests on pure functions
  3. refactoring from pure functions to object oriented code, if needed

 

In this session, I will describe:

  • The fundamental problem of legacy code
  • A quick intro to the standard technique for refactoring legacy code
  • Pure functions as a nominal format for programs
  • Refactoring techniques towards pure functions
  • Writing tests on pure functions
  • Refactoring from pure functions to object-oriented code

Leave a Reply