Chapter 32. Code in Motion

Laura Wingerd and Christopher Seiwald

The main point is that every successful piece of software has an extended life in which it is worked on by a succession of programmers and designers….

Bjarne Stroustrup

Early in the planning of this book, greg wilson asked contributors whether Beautiful Code was an apt title. “Much of what you’re going to discuss is software design and architecture, rather than code per se,” he wrote us.

But this chapter is about the code. It’s not about what the code does, nor is it about how beautifully it does it. Instead, this chapter is about how the code looks: specifically, how certain human-visible traits of coding make serial collaboration possible. It’s about the beauty of “code in motion.”

What you’re about to read is borrowed largely from Christopher Seiwald’s article, “The Seven Pillars of Pretty Code.”[109] In a nutshell, the Seven Pillars are:

  • Being “bookish”

  • Making alike look alike

  • Overcoming indentation

  • Disentangling code blocks

  • Commenting code blocks

  • Decluttering

  • Blending in with existing style

While these may sound like mere coding conventions, they’re more than that. They’re the outward manifestations of a coding practice that keeps product evolution in mind.

In this chapter, we’ll see how the Seven Pillars have supported a piece of code that has been part of a commercial software system for over 10 years. That piece of code is DiffMerge, a component of the Perforce software configuration management system. DiffMerge’s job ...

Get Beautiful Code now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.