Refactoring With Tests in Python: a Practical Exampleby@thedigicat
5,647 reads

Refactoring With Tests in Python: a Practical Example

tldt arrow
Read on Terminal Reader
Read this story w/o Javascript

Too Long; Didn't Read

When dealing with untested or legacy code refactoring is dangerous and tests can help us do it the right way. Test Driven Refactoring (TDR) is different from TDD, but the two are closely related. In this post I want to show you how you can safely refactor such a class using tests. The effectiveness of this methodology depends strongly on the quality of the tests themselves, possibly more than when developing with TDD. As you will be able to infer from the final result, there is no reason to keep an object-oriented approach for this code.

Company Mentioned

Mention Thumbnail
featured image - Refactoring With Tests in Python: a Practical Example
The Digital Cat HackerNoon profile picture

@thedigicat

The Digital Cat

A blog featuring in-depth posts about Python, Scala, TDD, devops, security and all things dev.


Receive Stories from @thedigicat

react to story with heart
The Digital Cat HackerNoon profile picture
by The Digital Cat @thedigicat.A blog featuring in-depth posts about Python, Scala, TDD, devops, security and all things dev.
Read the blog!

RELATED STORIES

L O A D I N G
. . . comments & more!