Software Design by Example in Python 10: A File Archiver
Software Design by Example began as a response to the shortcomings of Beautiful Code, but two specific things spurred me to finally write it and its JavaScript predecessor:
-
Mary Rose Cook’s Gitlet, which is a rational reconstruction of Git’s internals in JavaScript . (I’m currently working my way slowly through James Coglan’s Building Git, which goes deeper using Ruby.)
-
The seemingly simple question, “How does a debugger actually work?”
The book addresses the second of these near its end, but once learners understand how mock objects actually work, they can understand how to build and test a little version control system. The latter is as important as the former: I was in my forties when I learned that I could replace the entire filesystem for testing purposes using something like pyfakefs, and I don’t think other people should have to wait that long.
Chapter 10: A File Archiver was fun to write; my only regret is that I dodged the problem of atomic operations on multiple files, which turned out to be a lot harder than I knew. Coglan’s book tackles it, though, so if there’s ever a second edition of SDXPY, I hope to include it.
Terms defined: atomic operation, base class, compression (of file), Coordinated Universal Time, data migration, file locking, helper function, manifest, race condition, successive refinement, time of check - time of use, timestamp, top-down design, version control system.