Want to write defect-free software? Learn the Personal Software Process
Tags: codequality, learning, productivity
Published: 2018-09-03 22:47:44

---
title: Want to write defect-free software? Learn the Personal Software Process
published: true
description: PSP is too hard to follow for most of software developers. But I think you can adapt the PSP principles and get 80% of the benefits with 20% of the work. 
tags: #quality, #learning, #productivity
cover_image: https://thepracticaldev.s3.amazonaws.com/i/mut20ft48dsfcjdmt1cz.jpg
canonical_url: https://smallbusinessprogramming.com/want-to-write-defect-free-software-learn-the-personal-software-process/
---
I'm on a journey to [become a better software developer](https://smallbusinessprogramming.com/how-i-intend-to-become-a-better-software-developer/) by reducing the number of defects in my code. The Personal Software Process (PSP) is one of the few proven ways to achieve ultra-low defect rates. I did a deep dive on it over the last few months. And in this post I'm going to tell you everything you need to know about PSP.


### The Promise of the Personal Software Process (PSP)
Watts Humphrey, the creator of [PSP](https://en.wikipedia.org/wiki/Personal_software_process)/[TSP](https://en.wikipedia.org/wiki/Team_software_process), makes extraordinary claims for defects rates and productivity achievable by individuals and teams following his processes. He wrote a couple of books on the topic but the one I'm writing about today is [PSP: A Self-Improvement Process for Software Engineers](https://www.amazon.com/PSP-Self-Improvement-Process-Software-Engineers/dp/0321305493/) (2005).

![Software Defects by CMM Level vs the Personal Software Process](https://thepracticaldev.s3.amazonaws.com/i/y7y09r8l4qw7zcwuyemi.PNG)

This chart shows a strong correlation between the formality with which software is developed and the number of defects in the delivered software. As you can see, PSP/TSP delivered a shocking 0.06 defects/KLOC, which is about **100 times fewer defects than your average organization** hovering around [CMM level 2](https://en.wikipedia.org/wiki/Capability_Maturity_Model) (6.24 defects/KLOC). Impressive, right?

Humphrey further claims:
>Forty percent of the TSP teams have reported delivering defect-free products. And these teams had an average productivity improvement of 78% (Davis and Mullaney 2003). Quality isn't free--it actually pays.

**Bottom line: defects make software development slower than it needs to be. If you adopt PSP and get your team to adopt TSP, you can dramatically reduce defects and deliver software faster.** 

It seems counter-intuitive but Steve McConnell explains why reducing defect rates actually allows you to deliver software more quickly in this article: [Software Quality at Top Speed](https://stevemcconnell.com/articles/software-quality-at-top-speed/)

Of course, you can only get those gains if you follow a process like PSP. I'll explain more on that later but I want to take a small detour to tell you a story.


### Imagine your ideal job
Imagine you work as a software developer for a truly enlightened company--I'm talking about something far beyond Google or Facebook or Amazon or whomever you think is the best at software development right now. 

#### You are assigned a productivity coach
Now, your employer cares so much about developer productivity that every software developer in your company is assigned a coach. Here's how it works. Your coach sits behind you and watches you work every day (without being disruptive). He keeps detailed records of:

* time spent on each task
* programming tasks are broken down into categories like requirements, requirements review, design, design review, coding, personal code review, testing, peer code review, etc.
* non-programming tasks are also broken down into meaningful categories like meetings, training, administrative, etc.
* defects you inject and correct are logged and categorized
* anything else you think might be useful

#### Your coach runs experiments on your behalf
After you go home, your coach runs your work products (requirements, designs, code, documentation, etc.) through several tools to extract even more data such as lines of code added and modified in the case of code. He combines and analyzes additional data from your bug tracker and other data sources into useful reports for your review when the results become statistically significant.

Your coach's job is to **help you discover how to be the very best programmer you can be**. So, you can propose experiments and your coach will set everything up, collect the data, and present you with the results. Maybe you want to know:

* if test-first development works better for you than test-last development?
* are design reviews worth the effort?
* does pair programming work for you?
* do you actually get more done by working more than 40 hours a week?
* are your personal code reviews effective?

Those would be the kinds of experiments your coach would be happy to run.  Or your coach might suggest you try an experiment that has been run by several of your colleagues with favorable outcomes. The important point is that your coach is doing all the data collection and analysis for you while you focus on programming.

Doesn't that sound great? Imagine how productive you could become.

#### Unfortunately this is the real world so you have to be your own coach
This is the essence of the Personal Software Process (PSP). So, ***in addition to developing software, you also have to learn statistics, propose experiments, collect data, analyze it, draw meaningful conclusions, and adjust your behavior based on what your experiments reveal***.

### What the Personal Software Process gets right
Humphrey gets to the root of a number of the problems in software development:

* projects are often doomed by arbitrary and often impossible deadlines
* the longer a defect is in the project, the more it will cost to fix it
* defects accumulate in large projects and lead to expensive debugging and unplanned rework in system testing
* debugging and defect repair times increase exponentially as projects grow in size
* a heavy reliance on testing is inefficient, time-consuming, and unpredictable

Here's an overview of his solution:

>***The objective, therefore, must be to remove defects from the requirements, the designs, and the code as soon as possible. By reviewing and inspecting every work product as soon as you produce it, you can minimize the number of defects at every stage. This also minimizes the volume of rework and the rework costs. It also improves development productivity and predictability as well as accelerating development schedules***.

Humphrey convinced me that he's right about all aspects of the problem. He has data and it's persuasive. However, the prescription--what you need to do to fix the problem--is unappealing, as I'll explain in the next section. 

### Why almost nobody practices the Personal Software Process
PSP is too hard to follow for 99.9% of software developers. The discipline required to be your own productivity coach is beyond what most people can muster, especially in the absence of organizational support and sponsorship. Software development is already demanding work and now you need to add this whole other layer of thinking, logging, data analysis, and behavior changes if you're going to practice the Personal Software Process. 

Most software developers just aren't going to do that unless you hold a gun to their heads. And if you do hold a gun to someone's head PSP won't work at all. They'll just sabotage it or quit.

Here's a quote from Humphrey's book just to give you a taste for how detailed and process-driven PSP is:

>The PSP's recommended personal quality-management strategy is to use your plans and historical data to guide your work. That is, start by striving to meet the PQI guidelines. Focus on producing a thorough and complete design and then document that design with the four PSP design templates that are covered in Chapters 11 and 12. Then, as you review the design, spend enough time to find the likely defects. If the design work took four hours, plan to spend at least two, and preferably three, hours doing the review. To do this productively, plan the review steps based in the guidelines in the PSP Design Review Script described in Chapter 9....

It goes on from there...for about 150 pages. I can see how you could create 'virtually defect-free' software using this kind of process but it's hard for me to imagine a circumstance where you could get a room full of developers to voluntarily adopt such an involved process and apply it successfully.

But that's not the only barrier to adoption.

### Additional barriers to adoption
#### The Personal Software Process is meant to be taught as a classroom course
The course is prohibitively expensive. So, the book is the only realistic option available to most people.

You'll find that reading the book, applying the process, figuring out how to fill out all the forms properly, and then analyzing your data all without the help of classmates or an instructor is hard.

#### The book assumes your current process is some version of waterfall
TDD doesn't not play nice with the version of PSP you'll learn in the book. Neither does the process where you write a few lines, compile, run, repeat until you're done. It breaks the stats and the measures you need to compute to get the feedback you require to track your progress. It's not impossible to come up with your own measures to get around these problems but it's definitely another hurdle in your way. 

Languages without a compile phase (python, PHP, etc.) also mess up the stats in a similar way.

#### The chapters on estimating are of little value to agile/scrum practitioners
There's a whole estimating process in PSP that involves collecting data, breaking down tasks, and using historical data to make very detailed estimates about the size of a task that just don't matter that much in the age of agile/scrum. In fact, I didn't see any evidence that the Personal Software Process estimating methods are any better than just getting an experienced group of developers together to play planning poker.

#### It's very difficult to collect good data on a real-world project
If you're going to count defects and lines of code, you need good definitions for those things. And at first glance, PSP seems to have a reasonably coherent answer. But when I actually tried to collect that data I was flooded by edge cases for which I had no good answers. 

For example, a missing requirement caught in maintenance could take one hour to fix or it could take months to fix but you are supposed to record them both as requirement defects and record the fix time. Then you use the arithmetic mean for the fix time in your stats. So that one major missing requirement could completely distort your stats, even if it is unlikely to be repeated.

Garbage in, garbage out. Very concerning.

By the way, there's some free software you can use to help you with the data collection and analysis for PSP. It's hasn't been very useful in my experience but it's probably better than the alternative, which is paper forms.

#### Your organization needs to be completely on board
Learning the Personal Software Process is a huge investment. I think I read somewhere that it will take the average developer about 200 hours of devoted study to get proficient with the PSP processes and practices. Not many organizations are going to be up for that. 

PSP/TSP works because the people using it follow a detailed process. But most software development occurs at [CMM Level 1](https://en.wikipedia.org/wiki/Capability_Maturity_Model) because the whole business is at CMM Level 1. I think it's pretty unlikely that a chaotic business is going to see the value in sponsoring a super-process-driven software development methodology on the basis that it will make the software developers more productive and increase the quality of their software.

You could argue that the first 'P' in PSP stands for 'personal' and that you don't need any organizational buy-in to do PSP on your own. And that may technically be true but that means you'll have to learn it on your own, practice it on your own, and resist all the organizational pressure to abandon it whenever management decides your project is taking too long.

### Is the Personal Software Process (PSP) a waste of time then?
No, I don't think so. Humphrey nails the problems in software development. And PSP is full of great ideas. The reason most people won't be able to adopt the Personal Software Process--or won't even try--is the same reason people people drop their new year's resolutions to lose weight or exercise more by February: our brains resist radical change. There's a bunch of research behind this human quirk and you can read [The Spirit of Kaizen](https://www.amazon.com/Spirit-Kaizen-Creating-Lasting-Excellence-ebook/dp/B009Q0CQMA/) or [The Power of Habit](https://www.amazon.com/Power-Habit-What-Life-Business-ebook/dp/B00564GPKY/) if you want to learn more.

Humphrey comes at this problem like an engineer trying to make a robot work more efficiently and that's PSP's fatal flaw. Software developers are people, not robots. 

So, here are some ideas for how you can get the benefits from the Personal Software Process (PSP) that are more compatible with human psychology.

#### 1. Follow the recommendations without doing any of the tracking
Your goal in following PSP is to remove as many defects as possible as soon as possible. You definitely don't want any errors in your work when you give it to another person for peer review and/or system testing. Humphrey recommends written requirements, personal requirements review, written designs, personal design reviews, careful coding in small batches, personal code reviews, the development and use of [checklists](https://smallbusinessprogramming.com/code-review-checklist-prevents-stupid-mistakes/), etc. 

You can do all that stuff without doing the tracking. He even recommends ratios of effort for different tasks that you could adopt. Will that get you to 0.06 defects/KLOC? No. But you might get 80% of the way there for 20% of the effort.

#### 2. Adopt PSP a little bit at a time
To get around the part of your brain that resists radical change, you could adopt PSP over many months. Maybe you just adopt the recommendations from one chapter every month or two. Instead of investing 200 hours up front, you could start with 5-10 hours and see how that goes.

Or you could just track enough data to prove to yourself that method A is better than method B. And once you're satisfied, you could drop the tracking altogether. For example, if you wanted to know if personal design reviews are helpful for you, you don't need to do all the PSP tracking all the time. You could just setup an experiment where you could choose five tasks as controls and five tasks for design reviews and run that for a week or two, stop tracking, and then decide which design review method to adopt based on what you learn.

#### 3. Read the PSP book and then follow a process with a better chance of succeeding in the long run
[Rapid Development](https://www.amazon.com/Rapid-Development-Devment-Developer-Practices-ebook/dp/B00JDMPOB6/) by Steve McConnell is all about getting your project under control and delivering working software faster. McConnell, unlike Humphrey, doesn't ignore human psychology. In fact, he embraces it. I believe most teams would follow McConnell's advice long before they'd consider adopting the Personal Software Process (PSP). 

Most of the advice in Rapid Development is aimed at the team or organization instead of the individual, which I think it the correct focus. PSP is aimed at the individual but I can't see how you're going to get good results with it unless nearly everyone working on your project uses it. For example, if everyone on your team is producing crappy software as quickly as they can, your efforts to produce defect-free software won't have much effect on the quality or delivery date of the finished software.

### What I'm going to do
I develop e-commerce software on a team of two. My colleague and I have adopted a number of processes to ensure only high quality software makes it into production. And we've been successful at that; we've only had 4 critical (but easily fixed) defects and a handful of minor defects make it into production in the last year. Our problem is that we have quite a bit of rework because too many defects are making to the peer code review stage.

I showed my colleague PSP and he wasn't excited to adopt it, especially all the tracking. But he was willing to add design reviews to our process. So we'll start there and improve our processes in little steps at our retrospectives--just like we've been doing. 

Rod Chapman recorded a nice talk on [PSP](https://youtu.be/nWScAkGn-zw) and I like his idea of "moving left". If you want go faster and save more money you should move your QA to the left--or closer to the beginning--of your development process. That sounds about right to me.


### Additional resources
Here are some resources to help you learn more about PSP:

* [Nice overview of PSP](https://youtu.be/nWScAkGn-zw) by Rod Chapman (video)
* [Watts Humphrey speaking about TSP/PSP](https://youtu.be/4GFqodvsugY) (video)
* [A PSP case study supporting PSP](https://pdfs.semanticscholar.org/86b9/16e062217867543889fc2c487ac368414698.pdf) (pdf)
* [Research paper that casts doubt on the benefits of PSP](https://www.researchgate.net/profile/Karlheinz_Kautz/publication/258223987_Improving_Software_Developer%27s_Competence_Is_the_Personal_Software_Process_Working/links/54bda13f0cf218da9391b500/Improving-Software-Developers-Competence-Is-the-Personal-Software-Process-Working.pdf?origin=publication_detail) (pdf)
* [PSP: A Self-Improvement Process for Software Engineers](https://www.amazon.com/PSP-Self-Improvement-Process-Software-Engineers/dp/0321305493/) (book)
* [Link to the programming exercises for the book](https://smallbusinessprogramming.com/where-to-find-the-psp-programming-exercises/) (website)
* [Process Dashboard](https://www.processdash.com/) - a PSP support tool (website)


### Takeaways
It's tough to recommend the Personal Software Process (PSP) unless you are building safety-critical software or you've got excellent organizational support and sponsorship for it. Most developers are just going to find the Personal Software Process overwhelming, frustrating, and not very compatible with the demands of their jobs.

On the other hand, PSP is full of good ideas. I know most of you won't adopt it. But that doesn't preclude you from using some of the ideas from PSP to improve the quality of your software. I outlined three alternate paths you could take to get some of the benefits of PSP without doing the full Personal Software Process (PSP). I hope one of those options will appeal to you. 

*Have you ever tried PSP? Would you ever try PSP? I'd love to hear your thoughts in the comments.*