Coffee Mug Code

For Christmas, I received a hilarious coffee mug from my father-in-law.

Here is a photo of it.

coffee mug code

 

It’s an amusing little program. I’ve transferred the listing:

  while (working)
  {
     coffee.drink();
     work.execute();
     if (coffee == "empty")
     {
        if (coffeepot == "empty")
           coffeepot.brew();
        coffee.refill(); 
     }
  }

I love coffee and programming—it’s the perfect present for me. 

But there is something that I love even more about the mug:

The code is so simple, a layperson can understand it.

My 80-year-old father-in-law, who is not a programmer, could see the hilarity of the coffee-consuming code. Other non-programmer family members also immediately got the joke and smiled at its appropriateness.

And it had to be so. If the mug manufacturer had made the code too complicated and lost the joke, then no mugs would have ended up in Christmas stockings.

Not that it would fit on the side of a coffee mug, but 200 lines of over-complicated computer code indented to 6 levels, is not funny. On the contrary—it’s sad. A software developer would have to invest much time and effort to learn what is going on.

The mug’s lesson is simply this:

We ought to write our code so it’s easy to understand and simple to change.

That’s it.

Let me propose that we start 2021 out the right way and commit to writing easy-to-read code. To the best of our abilities, of course. And it’s a skill we can always get better at. There is no end goal. Imagine how much we could improve our working lives if we could stick to such a commitment! Who knows—maybe easy-to-read code will catch on with our fellow developers?

Tomorrow we’ll look at how we could improve the coffee mug code.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply