The typical approach to Data handling is
- read
- munge
- write
We want out code to reflect that structure. In doing so, we make it much easier to adapt the code to read from different sources and write to different destinations.
Continue readingThe typical approach to Data handling is
We want out code to reflect that structure. In doing so, we make it much easier to adapt the code to read from different sources and write to different destinations.
Continue readingThe heart of the code is the call to solve a single puzzle; the function tree_to_solution_string. We want to write a test that runs just this function. Getting there is not so easy.
This method is buried deep within the class SudokuSolver. But creating one of these essentially runs the entire code. In fact, we can redo our original test to run the code as a python call as opposed to a subprocess call. Lets’ start with that.
Continue readingOur test takes 5 seconds to run. That is not horrible, but it does not bode well for when we write more tests. We don’t want to explode that number, and we want to be able to write more focused test. I’m going to do some project setup that will enable us to do more development, including fine grained unit tests.
I’m going to start by using tox.
Continue reading180 lines of code is not horrible, but it is a lot to wrap your mind around all at once. In order to get oriented to the code, we’re going to take on one of the simpler refactorings. We are going to replace a bunch of the magic numbers with symbolic constants.
Continue readingThe code runs. How do me make sure that continues to be the case? Write a test.
Continue readingCongratulations, you got your code to run! You are done! Ship it!. Just don’t expect to be able to read it next month. You need to maintain it. You need to add new features. It is a mess.
Give yourself a well deserved break. Then come back to it.
Continue reading