Header Image

Refactoring C++ legacy code through pure functions

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
February 25 @ 10:45
10:45 — 11:30 (45′)

Online

Alex Bolboaca

× How can I help you?