Monday, March 3, 2014

Kata: Small step by step refactoring kata in C++

I've just made a small refactoring kata in C++.

Some of the tests in the initial code* were very slow because their code had to sleep some time in order for them to pass. Some other tests relied on having certain environment variable set to a given value.

The behavior that checked the environment variable and the one related to time were embedded in the Course class.

Through refactoring this behavior was isolated and extracted so that it could be injected into Course and then two fake classes were created to isolate Course in tests

Check the step by step refactoring in GitHub*.

Thanks to Leo Antoli for passing me the initial code in C#.

---------------------------

* This C++ code example works only for Windows.

No comments:

Post a Comment