Your Code as a Crime Scene, Second Edition
Use Forensic Techniques to Arrest Defects, Bottlenecks, and Bad Design in Your Programs
by Adam Tornhill
Jack the Ripper and legacy codebases have more in common than you’d
think. Inspired by forensic psychology methods, you can apply strategies
to identify problems in your existing code, assess refactoring
direction, and understand how your team influences the software
architecture. With its unique blend of criminal psychology and code
analysis, Your Code as a Crime Scene arms you with the techniques you
need to take on any codebase, no matter what programming language you
use.
Printed in full color.
Software development might well be the most challenging task humanity
ever attempted. As systems scale up, they also become increasingly
complex, expensive to maintain, and difficult to reason about. We can
always write more tests, try to refactor, and even fire up a debugger to
understand complex coding constructs. That’s a great starting point, but
you can do so much better.
Take inspiration from forensic psychology techniques to understand and
improve existing code. Visualize codebases via a geographic profile from
commit data to find development hotspots, prioritize technical debt, and
uncover hidden dependencies. Get data and develop strategies to make the
business case for larger refactorings. Detect and fix organizational
problems from the vantage point of the software architecture to remove
bottlenecks for the teams.
The original Your Code as a Crime Scene from 2014 pioneered techniques
for understanding the intersection of people and code. This new edition
reflects a decade of additional experience from hundreds of projects.
Updated techniques, novel case studies, and extensive new material adds
to the strengths of this cult classic.
Change how you view software development and join the hunt for better
code!
What You Need
You need to be comfortable reading code. You also need to use Git (or
Subversion, Mercurial or similar version-control tool).
Resources
Releases:
- P1.0 2024/02/01
- B3.0 2024/01/16
- B2.0 2023/08/31
- B1.0 2023/06/27
- Welcome to the Crime
Scene
- Identify Code That’s Hard to Understand
- Optimize for Understanding
- Understand That Typing Isn’t the Bottleneck in Programming
- Meet the Challenges of Scale
- Beware the Lure of Complexity Metrics
- Treat Your Code as a Crime Scene
- Take a Crash Course in Offender Profiling
- Apply Geographical Offender Profiling to Code
- Limit the Search Area: Spatial Patterns in Code
- Be Aware That Hotspots Reflect Probabilities
- Discover Hotspots: Create an Offender Profile of Code
- Mine the Evolution of Code
- Explore the Complexity Dimension
- Intersect Complexity and Effort
- Drive Refactoring via a Probability Surface
- Exercises
- Hotspots Applied: Visualize Code from the People Side
- Visualize Source Code
- Break Barriers via Language Agnostic Analyses
- Determine How Hot a Hotspot Is
- Understand That Bugs Breed Bugs
- Know That Information Is Only Good When Acted Upon
- Exercises
- Detect Deteriorating Structures
- Calculate Complexity Trends from Your Code’s Shape
- Inspect Negative Space in Code
- Prefer Trends over Absolute Values
- Evaluate the Growth Patterns
- Exercises
- Remediate Complicated Code
- Meet Your Brain on Code
- Spot Nested Logic That Taxes Working Memory
excerpt
- Refactor Complex Code via Simple Steps
- Evade Object Disorientation
- Use Abstraction as a Tool for Thinking
- Exercises
- Communicate the Business Impact of Technical Debt
- Know the Costs and Consequences of Technical Debt
- Know Why Half the Work Gets Done in Twice the Time
- Make the Business Case for Refactoring
- Fight Unplanned Work, the Silent Killer of Projects
excerpt
- Differentiate Remediation Time from Interest Payments
- Exercises
- Build Supportive Software Architectures
- Use Code as a Cooperative Witness
- Recognize the Paradox of False Memories
- Reveal the Dynamics of Change
- Inspect the Modus Operandi of a Code Change
- Understand the Reasons Behind Temporal Dependencies
- Exercises
- Architectural Reviews: Support Redesigns with Data
- Don’t Shoot the Messenger
- Use Sum of Coupling to Determine Architectural Significance
- Understand Change Coupling Algorithms
- Catch Architectural Decay
- Modularize Monoliths
- Exercises
- Use Beauty as a Guiding Principle
- Learn Why Attractiveness Matters
- Use Beauty in Code
- Analyze Pipes and Filters Architectures
- Analyze Layered Architectures
- Analyze Microservice Systems
- Reverse-Engineer Your Principles from Code
- Exercises
- Expose Hidden Bottlenecks: Delivery and Automation
- Understand What’s in an Architecture
- Profile Targets in Test Code
- Create a Safety Net for Your Automated Tests
- Avoid the Automated-Test Death March
excerpt
- Design for Human Problem-Solving
- Exercises
- Meet the Social Side of Your Code
- Meet Norms, Groups, and False Serial Killers
- Learn Why the Right People Don’t Speak Up
- Understand Pluralistic Ignorance
- Witness Groupthink in Action
- Discover Your Team’s Modus Operandi
- Mine Organizational Metrics from Code
- Exercises
- Discover Organizational Metrics in Your Codebase
- Kill a Project: A How-to Guide
- Analyze Hotspots for Coordination Issues
- Spot Conway’s Law in Your Code
- Act on Inter-Team Dependencies
- Exercises
- See How Technical Problems Cause Organizational Issues
- Have Your Code Motivate Retention
- Discover How Code Smells Lead to Coordination Problems
- Visualize Organizational Friction
- Measure the Truck Factor in Unhealthy Code
- Uncover the People Side of Code
- Exercises
- Build a Knowledge Map of Your System
- Know Your Knowledge Distribution
- Expand Your Mental Maps with Social Data
- Dig Below the Surface with Developer Patterns
- Use Fractal Figures to Mitigate Offboarding Risks
- Distinguish Use from Misuse
- Exercises
- Move Toward the Future
- Deepen Your Investigation
- Watch the Next Steps
- Stay Relevant: Programming in an AI World
- Watch Evolution in Reverse: Working with Low Code
- Write Evolvable Code
Author
Adam Tornhill is a programmer who combines degrees in engineering
and psychology. He’s the CTO and founder of CodeScene, where he develops
tools for software engineering intelligence. Adam is also the author of
multiple technical books, including Software Design
X-Rays and
Patterns in C, as well as a software researcher. Adam’s other interests
include modern history, music, retro computing, and martial arts.