How I intend to become a better software developer
Tags: professionalism, learning, programming, career
Published: 2018-05-22 13:57:09

---
title: How I intend to become a better software developer
published: true
description: There are only two economical ways to achieve extremely low defect rates in your code. You can learn the Personal Software Process (PSP) or use safer languages and tools. I plan to explore both options to improve my performance as a software developer.
tags: #professionalism, #learning, #programming, #career
cover_image: https://thepracticaldev.s3.amazonaws.com/i/856qcaqxmi5xzxn98ilv.jpg
canonical_url: https://smallbusinessprogramming.com/how-i-intend-to-become-a-better-software-developer/
---
My survey of the computer science literature suggests there are only two economical ways to achieve extremely low defect rates (< 1 defect per KLOC). The first way is to follow the Personal Software Process (PSP), which was created by Watts S. Humphrey at CMU. The second way is to use languages and tools that make it difficult to introduce errors into your code in the first place and easier to detect errors if you do manage to get some into your code. In this post I'm going to briefly discuss these two options and how I plan to explore them to become a better software developer.

But first, why do I want to do this? Because my experience building and maintaining software roughly tracks the data coming out of the research: defect-riddled code and all the testing, debugging, correcting, and rework that go along with it are incredibly wasteful. Our industry is [overflowing with failure](http://catless.ncl.ac.uk/Risks/). There's got to be a better way.

I've already written at length on [working on the most important thing](https://smallbusinessprogramming.com/working-on-the-most-important-thing/), [avoiding waste](https://smallbusinessprogramming.com/worthless-software-risks-prevention/), [code review checklists](https://smallbusinessprogramming.com/code-review-checklist-prevents-stupid-mistakes/), [optimal pull request size](https://smallbusinessprogramming.com/optimal-pull-request-size/), and so forth. So, in this post, I'm going to focus solely on what it takes to produce software with very low defect rates.


### Personal Software Process
PSP might best be described as the application of lean manufacturing principles to the activities of an individual developer. Programmers tend have poor insight into the various ways they make mistakes and create waste. They make the same mistakes over and over again and think they are awesome (me included). But the truth is that you are the one who is putting all those errors into your code, writing complicated code, writing unmaintainable code, and so on.

PSP teaches programmers how to track their work and their mistakes. And it provides programmers with strategies they can use to improve their performance over time. From what I hear, people who follow this process can improve dramatically.

### Better languages and tools
It's very difficult to write correct code in most languages. They're ambiguous and they allow programmers to do things that are almost certainly errors. Things get more interesting when you switch to a safer language like Ada and/or its ultra-safe subset called SPARK. This fits very well with my idea that [programming languages need to become significantly safer by default](https://smallbusinessprogramming.com/software-security-is-hopelessly-broken/) if we're ever going to improve software security.

#### Ada
Let's talk about Ada first. Strong typing, ranged types, contracts, and a really smart compiler help you avoid the stupid errors that languages like C/C++ and their derivatives ignore. So, if you choose to program in Ada, you're going to have an easier time detecting and localizing defects that you wouldn't even notice with another language. 

#### SPARK
If you want to take things to another level, you can look into using SPARK, which is a subset of Ada that can apply formal methods to your code. 

I know it sounds scary but I've been playing around with SPARK and I think it's awesome. First off, you don't need to know or do any serious math to use SPARK. SPARK can prove (or at least attempt to prove) your Ada contacts and type constraints automatically. If you just stopped right there, SPARK basically acts like that best static analyzer you've ever seen.

![accurate measurement](https://thepracticaldev.s3.amazonaws.com/i/mmqhvcqiod957kreyncz.jpg)

But you can go further. You can add assertions to your code and SPARK will attempt to statically prove that they will never be violated. How far you go is up to you but you can get your code--or some important parts of it--to the point that SPARK can demonstrate an absence of run-time errors. That means it can't crash from overflows, divide by zero, etc. 

Why would you want to do that? Four reasons:

1. Just like with TDD, writing your code in a way that SPARK can prove results in really well designed, simple, easy to read code. 
2. If SPARK is guaranteeing that whole class of errors can't happen, you don't need to write tests for as many paths through your code. 
3. There's a strong correlation between absence of run-time errors and the absence of logical errors. That means that code proved by SPARK tends to have fewer logical errors than code that hasn't been proved with SPARK. 
4. Once you understand what SPARK can do, you can stop thinking about those things when you are coding. It's similar to the way you don't have to agonize about your spelling when you write an email because the spell checker handles that for you. It's really impressive when you see it in action.

#### Just a word of warning
There's not much information on the web about Ada/SPARK (compared to more popular languages). And much of what's out there is outdated or just wrong. Both Ada and SPARK went through major changes in their latest releases that addressed some real pain points. Plus, Moore's law has made compiling and proving the correctness of your software orders of magnitude faster than they used to be.


### My plan
I'm already experimenting with Ada and SPARK. This kind of programming is a little different than I'm used to but I found some good resources and things are starting to click (see resources below). I plan to build a few toy applications with Ada/SPARK solidify my learning. 

For a bunch of reasons I won't go into here, it's unlikely that Ada will ever be a mainstream language. So, I'm not under any delusions that I'll get to write production code in it any time soon. But, I can already see that some of the concepts can be applied to any programming language with very little effort. And I'm looking forward to using some of those ideas to improve my code at my day job.

As for PSP, I ordered the book [PSP: A Self Improvement Process For Software Engineers](https://www.amazon.com/PSP-Self-Improvement-Process-Software-Engineers/dp/0321305493/) by Watts S. Humphrey and I plan to work through it and the accompanying programming exercises straight away. PSP is language agnostic so if you're interested in upping your game immediately, you might want to start with PSP and explore Ada/SPARK later.

**Update: 2018-09-03:**
I've been studying PSP for the last few months and I've written a [summary](https://smallbusinessprogramming.com/want-to-write-defect-free-software-learn-the-personal-software-process/) of what I've learned so far.


### Takeaways
Both PSP and Ada/SPARK are more prominent in the safety-critical, mission-critical, and high security sides of our profession. I've never heard any of the web development gurus mention this stuff so, I have no idea how well these tools will apply to my day job as a back-end ecommerce developer. My guess is that almost anything I can do to prevent defects from getting into our code base will be worth doing. 

The research is very clear on [the rising costs of fixing defects in the later stages of the development lifecycle](https://ntrs.nasa.gov/archive/nasa/casi.ntrs.nasa.gov/20100036670.pdf). So, I can give up some speed on coding to save time on testing, debugging, and unplanned rework. The trick will be finding the sweet spot.

*Would you ever consider learning PSP or Ada/SPARK? I'd love to hear your ideas in the comments.*


### Resources
**How to achieve ultra-low defect rates:**
Paper: [The Fumble Programmer](https://proteancode.com/wp-content/uploads/2018/02/the_fumble_programmer.pdf) by Rod Chapman
Video: [Murphy vs Satan: Why Programming secure systems is still hard](https://youtu.be/ruuZVFbRlr4) by Rod Chapman
Should we trust computers? ([video](https://youtu.be/qZrHVXxIOCA) or [word doc](https://s3-eu-west-1.amazonaws.com/content.gresham.ac.uk/data/binary/36/20Oct15MartynThomas_ShouldweTrust.docx)) by Martyn Thomas
Making Software Correct by construction ([video](https://youtu.be/03mUs5NlT6U) or [word doc](https://s3-eu-west-1.amazonaws.com/content.gresham.ac.uk/data/binary/2464/2017-05-02-MartynThomas_MakingSoftware.docx)) by Martyn Thomas
Safety-Critical Systems ([video](https://youtu.be/E0igfLcilSk) or [word doc](https://s3-eu-west-1.amazonaws.com/content.gresham.ac.uk/data/binary/2360/2017-01-10-MartynThomas_SafetyCritical.docx)) by Martyn Thomas

**Learn PSP:**
Book: [PSP: A Self Improvement Process For Software Engineers](https://www.amazon.com/PSP-Self-Improvement-Process-Software-Engineers/dp/0321305493/) by Watts S. Humphrey
Video: [An Introduction to PSP](https://youtu.be/4GFqodvsugY) by Watts S. Humphrey

**Learn Ada/SPARK:**
Pluralsight Course: [An Introductions to Ada 2012](https://www.pluralsight.com/courses/ada-2012-introduction)
Contract-Based Programming in Ada 2012 ([video](https://ftp.osuosl.org/pub/fosdem/2018/AW1.125/ada_contracts.webm) or [slides](http://www.jacob-sparre.dk/reliability/Contract-based-programming-2014.pdf)) by Jacob Sparre Andersen
Website: [Introduction to embedded programming with Ada](http://www.inspirel.com/articles/Ada_On_Cortex.html)
Book: [Building High Integrity Applications with SPARK](https://www.amazon.com/Building-High-Integrity-Applications-SPARK/dp/1107656842/) by John W. McCormick and Peter C. Chapin
Website: [Ada Information Clearinghouse](http://www.adaic.org/)