|Your Code as a Crime Scene
||[Apr. 13th, 2016|11:55 am]
De Horror Vacui
Your Code as a Crime Scene: Use Forensic Techniques to Arrest Defects, Bottlenecks, and Bad Design in Your Programs, by Adam Tornhill|
This is a delightful book with a delightful technique for determining where errors and inefficiencies in code are likely to occur. Tornhill's observation is that you can use the techniques coming from criminal justice on the code you're currently working on -- especially in large projects with large groups. The most important factor is where changes occur, basically which classes are changed and how frequently.
If you change a piece of code frequently, that's bad.
You can get all of this data from a version control system like GitHub. These systems track changes, and data is just a few scripts away. By analyzing this data, you can find which parts of your code are stable and which are unstable. You can similarly find correlations between code changes -- those correlations generally indicating bad encapsulation practices (pieces of the program aren't as independent as they should be).
You can also look at various metrics in the code, such as indentation, to give you other clues about problems. A large amount of indentation usually means that there is a lot of complexity in your code, something you cant to avoid. And increasing complexity in the codebase means that the code is deteriorating, probably under various hacks. You can even keep track of the revisions to your test code -- and woe to you if you revise your test code more than your application.
With chapter names like "Creating an Offender Profile", "Treat Your Code as a Cooperative Witness", and "Norms, Groups, and False Serial* Killers" the book, despite being technical and prescriptive, is lively and entertaining throughout. It has plenty of illustrations...mostly useful. I very much recommend this book, even if you're not coding.**
Other Books, 2016:
25. Knight of Shadows, Roger Zelazny
24. Death on the Nile, Agatha Christie
23. Feynman Lectures on Computation, Richard Feynman
22. Effective Computation in Physics, Anthony Scopatz and Kathryn D. Huff
21. How to Fail at Everything and Still Win Big, Scott Adams
20. Sign of Chaos, Roger Zelazny
19. Murder Must Advertise, Dorothy Sayers
18. The Mythical Man-Month, Fredrick Brooks
17. Blood of Amber, Roger Zelazny
16. Understanding Computation, Tom Stuart
15. Social Class in the 21st Century, Mike Savage
14. Design for Great-Day, Alan Dean Foster and Eric Frank Russell
13. QED: The Strange Theory of Light and Matter, Richart Feynman
12. SciPy and NumPu, Eli Bressert
11. Elementary Quantum Mechanics in One Dimension, Robert Gilmore
10. The Trumps of Doom, Roger Zelazny
9. Your Code as a Crime Scene, Adam Tornhill
8. Upland Outlaws, Dave Duncan
7. Identity Economics, George Akerlof and Rachel Kranton
6. The Courts of Chaos, Roger Zelazny
5. Nudge, Richard Thaler and Cass Sunstein
4. The Cutting Edge, Dave Duncan
3. The Nature of Software Development, Ron Jeffers
2. The Death of Chaos, L.E. Modesitt, Jr.
1. Kivy -- Interactive Applications and Games in Python, Roberto Ulloa
* One of my students used the Cereal - Serial Killer pun, reminding me of one of the best Sandman storylines.
** Which I currently am. I just got a puzzle game to help my students learn logic to a state that I'm only mostly embarrassed to put it up on-line.