Programming Articles

Programming like its 1977: exploring the Atari VCS

May 2024

Earlier this year I started a new hobby: writing games on the Atari VCS. The Atari VCS -- or Atari 2600 as later versions were labeled -- is a curious piece of hardware. It's heavily constrained with its 128 bytes(!) of RAM, no operating system, and limited types of sprites. The good news are that you're compensated for the lack of RAM by a full 4K of Read Only Memory (ROM) at your disposal. Wonderful. The slight downside is that you have to fit all your game logic, graphics, and sounds into those 4K. As if that wasn't constraining enough, you also have to trace and time the electron beam on the TV to output graphics. Just saying. Still, people at the dawn of computer gaming managed to squeeze amazing art out of this platform.

Read More

The 0x programmer: the curse of a perfect memory

March 2022

How would a person with perfect and limitless memory perform as a programmer? Picking up the latest Perl syntax or the intricacies of Kubernetes would be effortless. And passing any AWS certification of your choice would be a lazy pass through the relevant documentation. While the benefits are obvious, a perfect memory won't necessarily turn us into coding wizards. In fact, I suspect that the contrary is true: that person would struggle as a developer. Let's explore how our cognitive constraints guide software design.

Read More

Why I Write Dirty Code: Code Quality in Context

October 2019

Over the past decade I have noticed a change in how I approach code quality. I still consider code quality important, but only in context. In this article I want to share the heuristics I use to decide when high-quality code is called for, and when we can let it slip. It's all about using data to guide when and where to invest in higher code quality, and how it can be a long-term saving to compromise it. Let's start by uncovering the motivation for investing in code quality.

Read More

My Five Worst Bugs: Lessons Learned In System Design

August 2018

My two decades in the software industry have been rewarding, interesting, and fun. However, there has also been plenty of frustration, horrible mistakes, and many sleepless nights. This month I'm celebrating 21 years as a professional developer, so let's take this opportunity to revisit some epic failures from the past as each one of them provided a learning experience that influenced the way I design software today.

Read More

Q&A on Software Design X-Rays -- Fix Technical Debt with Behavioral Code Analysis

March 2018

I did a Q&A with my publisher on my new book, Software Design X-Rays -- Fix Technical Debt with Behavioral Code Analysis.

Read the Q&A

Beyond Functional Programming: Manipulate Functions with the J Language

by Adam Tornhill, February 2017

The Pragmatic Programmer recommends that we learn at least one new language every year. To be effective, the languages we learn should differ sufficiently from those we already master and ideally introduce us to a new paradigm too. Learning a different programming language affects the way we view code. A new paradigm may even alter our problem solving abilities by reshaping the way we think. The J programming language offers both of these qualities.

Read the Article

Software (r)Evolution

Software (r)Evolution is a series of articles that explore novel approaches to understanding and improving large-scale codebases. Along the way we'll use modern data science to uncover both problematic code as well as the behavioral patterns of the developers that build your software. This combination lets you to identify the parts of your system that benefit the most from improvements, detect organizational issues and ensure that the suggested improvements give you a real return on your investment.

  1. Part 1 - Predict Maintenance Problems in Large Codebases, August 2016.
  2. Part 2 - Novel Techniques to Prioritize Technical Debt, August 2016.

Best Articles of 2015

by Adam Tornhill, February 2016

I'm proud to announce that my articles made it to the top of ACCU's survey for people's favorite articles of 2015. ACCU publishes two magazines. My article Meet the Social Side of Your Codebase made it to the top in the Overload magazine while Writing a Technical Book made the second place in the CVu magazine. These awards actually mean a lot to me. Yes, really, they do. Let me explain how it all started.

Read More

Kill the Clones: How Temporal Coupling helps you identify Design Problems in large-scale Systems

by Adam Tornhill, December 2015

In this article we put the CodeScene analysis tool to work on a real-world system: Microsoft's ASP.NET MVC. You'll see why and how Change Coupling helps us design better software as we detect a number of possible quality issues in the code.

Read the Article

Analyzing Code Churn with Clojure and Zoo

June 2015

Clojure in combination with the powerful Incanter library is a great platform for data analysis. In this article we'll put Clojure to work as you learn to calculate and visualize code churn trends.

Read the Article

The Code as a Crime Scene Gallery

May 2015

A best of collection from some of the open source projects I've analyzed with the Code as a Crime Scene techniques.

Visit the gallery

Writing a Technical Book: Motivation, Publishing and how to stay focused without ruining your Life

May 2015

Do you dream of writing your own technical book? I hope you do – our programming profession needs more high-quality books. In our fast evolving field there’s an endless amount of new topics to cover and timeless ideas to rediscover. This article is here to help you get started. I’ll make sure to give you a high-level overview on everything from the initial planning to tips on different publishing models. You’ll also learn about the motivational hacks I used to stay on track and make a steady progress on my own books.

Read the article

This article was published in CVu Volume 27 (2) in May 2015

Meet the Social Side of Your Codebase

April 2015

Let’s face it — programming is hard. You could spend an entire career isolated in a single programming language and still be left with more to learn about it. And as if technology alone weren’t challenging enough, software development is also a social activity. That means software development is prone to the same social biases that you meet in real life. We face the challenges of collaboration, communication, and team work.

This article was published in PragPub issue 70, April 2015

Read the article

Why I view Code as a Crime Scene

March 2015

The following interview is a Q&A I did for the Pragmatic Bookshelf to present my new book Your Code as a Crime Scene.

The interview was done by my project editor, Fahmida Y. Rashid. I chose to publish it here as well for a reason; Over the past years I've delivered several presentations about this topic. One of the most common questions I get is how I came up with the idea. So, here it is - this is why I view Code as a Crime Scene!

Read the interview

Beauty in Code

July 2014

The challenge of all software design is to control complexity. Less complexity means that our programs are easier to understand, reason about and evolve. This article shows how we can use beauty as a mental tool for that purpose. Starting in the field of the psychology of attractiveness, we'll expand its theories on physical beauty to also cover code. In the process we'll learn a bit about Clojure, meta-programming and destructuring.

This article was published in Overload 121, June 2014

Read Beauty in Code

The Soundtrack to Code

January 2014

To a programmer, noisy work environments are a devastating killer of job performance. Surprisingly, most workplaces still seem to ignore the problem and leave the root causes untreated. Instead the symptoms of a deep, severe problem are left to the individual programmers to address. The following essay discusses the consequences, perils and possible remedies from a cognitive perspective.

This article was published in C Vu Volume 25, Issue 6

Read Soundtrack to Code

Lisp for the Web - The Book

January 2014

I'm proud to announce my new book Lisp for the Web. The idea with the book is to convey a feeling of how it is to develop in Lisp rather than focusing on the details. In the process we'll find out how a 50 years old language can be so well-suited for modern web development and yes, it's related to all those parentheses.

You can get the book at Leanpub for any price you want (free included).

Code as a Crime Scene

November 2013

Technical challenges rarely come in isolation. In any large-scale project they interact with social and organizational aspects. To address that complexity we need to look beyond the current structure of the code. We need strategies to identify design issues, a way to find potential suspects like code smells and team productivity bottlenecks. Where do you find such strategies if not within the field of criminal psychology?

An earlier version of this article was published in Overload 117

Read More

The Signs of Trouble: On Patterns, Humbleness and Lisp

October 2012

As software developer and author of a technical book on patterns I obviously find value in the pattern format. And as a psychologist I see the links to our cognitive capabilities and the social value of patterns. In this article I will detail my view on patterns and the value I see in them. Since patterns are a controversial topic, I will build the article around the criticism against patterns. Let the critics have the first word.

Read More

Patterns in C - The Book

September 2012

Dear reader, I'm pleased to announce my first book, Patterns in C. Patterns in C is a collection of idioms, design and architectural patterns in the C programming language. The book highlights the value of patterns. In the right context, patterns serve as an excellent tool for communication and reasoning. The book provides a C programmer with techniques to benefit from the growing body of knowledge captured in patterns.

Read More or visit the book's homepage.

Development Fuel: software testing in the large

July 2012 (co-autored by Adam Tornhill and Seweryn Habdank-Wojewodzki)

As soon as a software project grows beyond the hands of a single individual, the challenges of communication and collaboration arise. We must ensure that the right features are developed, that the product works reliably as a whole and that features interact smoothly. And all that within certain time constraints. These aspects combined place testing at the heart of any large-scale software project.

Read Development Fuel

Code Patterns

June 2011

Code Patterns discuss the challenges involved in introducing and teaching TDD. It investigates something we programmers rarely reflect over, the form and physical layout of our code, and illustrates how it may be used as a teaching-tool.

Read Code Patterns here .

Lisp for the Web

March 2008

A case study in developing a three-tier web application using Common Lisp. The article was published in the 2008 April issue of C Vu.

Read the article here .

The code for the developed application (Retro Games) is available here .

Design in Test-Driven Development

April 2007

An article discussing the impact of TDD on the development process.

Design in Test-Driven Development was published in Overload 78, April 2007 .

Solving FizzBuzz using C++ compiler error messages

April 2007

Using C++ template metaprogramming, I'll try to solve FizzBuzz by having the compiler output the solution as error messages.

Read the article here . The article was posted on reddit in April, 2007.

Objects for States

May 2006

Originally captured in Design Patterns, Objects for States is described in close conjunction with the Singleton pattern. This article will explain why this is an unfortunate combination and investigate better alternatives for implementing the pattern in C++.

Objects for States (pdf, 116 kb), published in Overload 73, June 2006

Download the full source code here (zip, 17 kb).

Idiomatic Expressions

February 2006

As a language evolves, certain efficient patterns arise. These patterns get used with such a high frequency and naturalness that they almost grow together with the language and generate an idiomatic usage for the practitioner of the language. This article captures some of these idiomatic expressions.

Idiomatic Expressions in C (164 kb), published in C Vu 18.1, February 2006

Patterns in C

June-September 2005

This series has been published in the C Vu, which is a bimonthly ACCU publication.

All documents are stored as PDF.

Patterns in C - Part 1 (196 kb), published in C Vu 17.1, February 2005

Patterns in C - Part 2: STATE (237 kb), published in C Vu 17.2, April 2005

Patterns in C - Part 3: STRATEGY (197 kb), published in C Vu 17.3, June 2005

Patterns in C - Part 4: OBSERVER (210 kb), published in C Vu 17.4, August 2005

Patterns in C - Part 5: REACTOR (284 kb) with full source code (zip, 13 kb), published in C Vu 17.5, October 2005