Software can be systematic

Writing software should be, and can be, a systematic and repeatable process.

It all starts with a cat

Do you remember keyboard cat? A cat playing a keyboard doesn’t seem like much, but it has had a big influence on how we program. Keyboard cat was sitting at a keyboard, like we were, but unlike us keyboard cat was having a good time. This is not to say that programming is not fun—it often is—but keyboard cat seemed to be lost in the music in a way that we found difficult to achieve in code.

Around the same time we started teaching Scala. Scala offers a lot of flexibility and this can make it difficult for beginners to be productive. Drawing on lessons we’d learned from How to Design Programs we realised we could stop teaching Scala as a collection of language features, and instead teach programming strategies, and only introduce the language features as we needed them.

Two things happened once we started doing this. Our students learned a lot faster and, to our surprise, our own code became easier to write and simpler to maintain. When we could code in hours what used to take days we realised we’d attained the keyboard cat nature we’d been after.

So what is a programming strategy? It’s a technique that guides us to working code. Sometimes they are very prescriptive and will lead us to code in a very mechanical way. Sometimes they are more descriptive, providing general advice. Altogether they make up a mental toolbox for producing code in a systematic and repeatable way.

It’s probably time for an example.

A very prescriptive strategy is algebraic data types. It says: if the data can be described in terms of logical ands and logical ors, then it should be implemented using sealed trait and final case classes. A more descriptive strategy is read the literature, which is reminder that any problem we face has probably already been solved, and a bit of looking for someone else’s solution can save us a lot of time.

Want to learn more? There is only so much we can fit into this web page, so if you’d like to learn more get in touch