Coding like a drummer

David Blanc
AndroidPub
Published in
5 min readJul 31, 2018

When I started drumming as a kid, all I wanted to do was sit in front of a drum set and start playing. As it turned out, it takes a lot of practice to get comfortable playing lots of different songs and styles. In particular, it required work in three specific areas:

  • First, the rudiments: those are simple strokes and patterns that you practice over and over again to improve speed and stick control. It might seem a bit boring for a kid who just wants to bang on the drums, but it’s essential to build up confidence around your kit.
  • Second, you need to develop your rhythmic culture by listening to lots of different styles, so you have a wide collection of rhythms to borrow from to build your own style.
  • And finally comes coordinated independence, which is basically learning to resist that impulse to hit a drum or cymbal with your right hand whenever your right foot kicks the pedal. You‘re aiming for more independence between your limbs to gain more freedom as you play.

So what does drum practice have to do with programming in general, and particularly Android? Probably not much, but it provides an interesting analogy for the young programmer trying to get better at what he does.

Just like the 12 year old boy I used to be, every new programmer just wants to sit in front of a computer and throw a few lines of code together to have a working app. Having a visible result that you can play with is just as satisfying as jamming along your favorite tunes. But if you don’t want to put in the practice hours, your drumming skills will remain very limited.

In the same way, programming is more than just one skill and you will need to work on a few different aspects to become a well rounded and proficient programmer. So what skills do you need to work on?

Rudiments

Any rhythm on the drums can be broken down into smaller units, little building blocks that form extraordinarily intricate patterns once you assemble them together. But if you want to start with the complicated rolls and fills, you’ll soon grow frustrated at the difficulty. What you need is to start small, and work on each of those tiny elements one by one before you can combine them and elaborate some funky beats. You don’t build a tower in one go: you build it brick by brick.

In the same way, programming is an art (or is it a science?) that tries to solve certain problems with algorithms. Different problems call for different solutions, but the elementary building blocks that you will use have been around for decades. They’re the classic data structures and algorithms that you learn about is your CS 101 class.

Arrays, lists, trees or graphs are the kind of objects you must get comfortable with. If you want to up your game, you need to learn about those structures and how to manipulate them efficiently. You will also need to study the most common algorithms: sorting a list, traversing a graph, handling a priority queue… Just experiment with them to develop that instinct that helps you recognize patterns in the problems you’re trying to solve and guides you towards the most efficient and time tested solutions.

Reading classic algorithm books like “The Algorithm Design Manual” by Steven Skiena will help you with that aspect, but practicing is important. Website like Codingame can provide some excellent practice material through funny exercises that you can solve in whatever programming language you’re comfortable with.

Rhythmic culture

A good drummer should be able to play more than one style. But even if you want to specialize on a certain genre, you will need to listen to countless hours of music to get a wide variety of beats you can draw from to build your own signature. In a similar fashion, a programmer needs to know his programming platform and language inside and out to be able to tackle any challenge that comes up.

Spend time reading documentation, blog posts, watching conferences, diving into other people’s code to learn the tools of the trade and fill your bag with more and more tricks. Investigate well known libraries and frameworks to make sure you won’t have to reinvent the wheel every day but instead will be able to use what is already readily available for you.

If you want to be an Android developer, countless lists of libraries worth knowing exist, including, among others, Dagger, OkHttp, Retrofit, RxJava, ButterKnife, Timber, Lottie…

Coordinated independence

Finally, one of the greatest challenges that a drummer faces is coordination and independence. Basically, you body is wired in such a way that your limbs tend to work together naturally, which kind of limits what you can play. Your hands are tightly coupled with your feet, and your first drumming lessons are very often spent learning how to loosen that relationship. Being able to play simultaneously different patterns with each limb brings more freedom and creativity to your drumming.

Tight coupling is also the kind of problem that can limit your programming abilities. Clean architecture principles and design patterns are what will help you prevent dependencies where they’re not needed. Any program can very quickly degenerate into an unmaintainable bowl of spaghetti code. Keeping things clean and concerns separated is the key to a long lasting program that can evolve freely to support new use cases and requirements.

The important principle here is that your business rules are the center and most valuable part of your program and that code must be protected as much as possible from being contaminated by details like database implementations, framework dependencies or platform specificities. An ability to coordinate all those bricks and make them work together while keeping your core business code independent enough is what truly sets a good programmer apart.

So look into software craftmanship communities, design principles or architecture books to understand the basics of a good design. Lots of great reading exist on these matters, written by people like Martin Fowler, Kent Beck or Uncle Bob Martin (Clean architecture, by Robert C. Martin is a must read).

One last thing: less is more

As we conclude this drumming analogy, one last piece of advice comes to mind. Most young drummers think that they can show how good they are by playing extremely complicated rhythms and trying to combine so many strokes as fast as they can. But with maturity, they begin to understand that playing less notes is often preferable. The same principle applies to programming: you won’t prove how talented you are by coding extremely complex algorithms but by always finding the simplest solution to a given problem. I recently read that good programmers should be noticed based on how simple the code they produce looks. Or as Saint Exupery used to put it:

“Perfection is achieved not when there is nothing more to add, but when there is nothing left to take away”

--

--

David Blanc
AndroidPub

Lead Android developer at @InformatiqueBP. I love Android, Kotlin and coding in general. @speekha on Twitter. Author of HttpMocker