Your Code as a Crime Scene: Use Forensic Techniques to Arrest Defects, Bottlenecks, and Bad Design in Your Programs (The Pragmatic Programmers)

Your Code as a Crime Scene: Use Forensic Techniques to Arrest Defects, Bottlenecks, and Bad Design in Your Programs (The Pragmatic Programmers)

Language: English

Pages: 190

ISBN: 1680500384

Format: PDF / Kindle (mobi) / ePub


Jack the Ripper and legacy codebases have more in common than you'd think. Inspired by forensic psychology methods, you'll learn strategies to predict the future of your codebase, assess refactoring direction, and understand how your team influences the design. With its unique blend of forensic psychology and code analysis, this book arms you with the strategies you need, no matter what programming language you use.

Software is a living entity that's constantly changing. To understand software systems, we need to know where they came from and how they evolved. By mining commit data and analyzing the history of your code, you can start fixes ahead of time to eliminate broken designs, maintenance issues, and team productivity bottlenecks.

In this book, you'll learn forensic psychology techniques to successfully maintain your software. You'll create a geographic profile from your commit data to find hotspots, and apply temporal coupling concepts to uncover hidden relationships between unrelated areas in your code. You'll also measure the effectiveness of your code improvements. You'll learn how to apply these techniques on projects both large and small. For small projects, you'll get new insights into your design and how well the code fits your ideas. For large projects, you'll identify the good and the fragile parts.

Large-scale development is also a social activity, and the team's dynamics influence code quality. That's why this book shows you how to uncover social biases when analyzing the evolution of your system. You'll use commit messages as eyewitness accounts to what is really happening in your code. Finally, you'll put it all together by tracking organizational problems in the code and finding out how to fix them. Come join the hunt for better code!

What You Need:

You need Java 6 and Python 2.7 to run the accompanying analysis tools. You also need Git to follow along with the examples.

 

 

 

 

 

 

 

 

 

 

 

you look at the mean, you see that it, too, decreases. Let’s see what that means for your programs. Evaluate the Growth Patterns When you’re analyzing complexity trends, the interesting thing isn’t the numbers themselves but the shape of the evolutionary curve. The following figure shows the shapes you’re most likely to find in a typical codebase. The dip in the curve in Case B generally is a sign of a refactoring, because the code got simpler. Case C is also common because there’s little

first day, the team gathers to discuss two design alternatives. You get a short overview before the team leader suggests that you all vote for the best alternative. It probably sounds a little odd to you. You don’t know enough about the initial problem, and you’d rather see a simple prototype of each suggested design to make an informed decision. So, what do you do? If you’re like most of us, you start to look around. You look at how your colleagues react. Since they all seem comfortable and

effectively step through a hundred thousand lines of entangled code. The problem also gets worse with the size of your development team, because everyone is working separately. Nobody has a holistic picture of the code, and you risk making biased decisions. In addition, all large-scale codebases have code that no one knows well or feels responsible for. Everyone gets a limited view of the system. Decisions made based on incomplete information are troublesome. They may optimize one part of the

patterns, 149–152 identifying hotspots in codebase, 23–31, 36– 45 identifying main developers, 142–144 knowledge map visualization, 154 main-dev analysis, 142– 143, 157 main-dev-by-revs analysis, 143 refactoring-main-dev analysis, 141 revisions command, 27, 99 setup instructions, 8 summary option, 27 temporal coupling analysis, 72, 78–82, 96, 109–111 --temporal-period 1 option, 140 visualization samples, 157 code reading, 181 code reviews knowledge map, 160 prioritizing, 6, 32 shape analysis, 56

time. Explore the Geography of Code We need a geography of code. Despite its lack of physics, software is easy to visualize. My favorite tool is Code City.3 It’s fun to work with and matches the offender-profiling metaphor well. The following figure shows a sample city generated by the tool. 3. http://www.inf.usi.ch/phd/wettel/codecity.html report erratum • discuss Chapter 2. Code as a Crime Scene • 18 A city block represents a package, and each class is a building. The number of methods

Download sample

Download