paint-brush
Refactoring With Tests in Python: a Practical Exampleby@thedigicat
5,656 reads
5,656 reads

Refactoring With Tests in Python: a Practical Example

by The Digital Cat32mApril 11th, 2020
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

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
The Digital Cat

The Digital Cat

@thedigicat

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

About @thedigicat
LEARN MORE ABOUT @THEDIGICAT'S
EXPERTISE AND PLACE ON THE INTERNET.
L O A D I N G
. . . comments & more!

About Author

The Digital Cat HackerNoon profile picture
The Digital Cat@thedigicat
A blog featuring in-depth posts about Python, Scala, TDD, devops, security and all things dev.

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite
Also published here