Get rid of those cheat sheets!

This is another post motivated by Twitter: It’s about those cheat sheets, for example those showing C++ operator precedence, that some people have stick to their monitor or cubicle wall. Unless they contain something you are just learning and almost everybody else knows, you should get rid of them.

Here is the Tweet that triggered my thoughts on the topic:

My first reaction was “Neat! I need one of those too!”. But then something dawned on me: why would anyone truly need something like this?

Cheat sheets can lead to unreadable code

If you need a cheat sheet to write a piece of code, then you are probably something unusual. Otherwise you would not need the cheat sheet. But if you need the cheat sheet to write the code, there is a good chance that whoever will read it also needs some source of information to decipher it.

In the case of the operator precedence, Stephan is probably well aware of the precedence of multiplicative operators over additive ones. Maybe the information he needs now and then is about the pointer-to-member operators versus shift operators, or binary or versus logical or. My point is, if he does not clarify his intent by using parentheses, most people who read his code will have to look up the very same information as well to fully understand it.

Maybe Stephan does not use his cheat sheet to actually write code, but he needs it to decipher what someone else has produced. We won’t know. But unless there is a very harsh requirement on compile time performance that does not even allow for some redundant parentheses to be parsed, the code that needs this cheat sheet should be improved by making the intended precedence obvious.

In Stephan’s case, that requirement may well be in place. He maintains the standard library shipped with Visual Studio, so his code will be compiled millions of times a day around the world.

Some cheat sheets are Ok

Cheat sheets about language basics

With “basics” I mean stuff that you need for a few weeks while you are learning something new. Stuff that everybody else who has been using that language, library or feature for some time already knows. Those cheat sheets help you learn by actually using the stuff you can’t remember at once, and they will be obsolete in a few weeks, once you learned their content. They save some time you’d otherwise spend googling the same thing again and again. I am building a basics cheat sheet myself while I learn to work with Unity3D and C#, and another for Python.

Cheat sheets for tools

Tools are a great area for cheat sheets as well. We all want to get more productive, so the cheat sheets with all the keyboard shortcuts and less frequently used git commands can only help. They help because we’re the only ones that actually see the information on the in action and nobody gets confused by the weird wizardry we are doing.

Cheat sheets are not always worth the effort

Unless we are in the process of learning something we often need, producing cheat sheets can be a waste of time, ink and tree lives. If we don’t need them frequently, we probably even forget that we have them or that the information we need is on them. We just launch our browser and google for the information again.

On the other hand, if we need the information frequently, it’s only a matter of time before we have memorized it and can get rid of the cheat sheet. If you actually write cheat sheets yourself instead of just downloading and printing them, that action alone can be a huge help in memorizing the information. I have written many cheat sheets that I never had to look at, just to throw them away a few weeks later. They have served their purpose.

Conclusion

The art in programming is to write great stuff with code that everybody could write. Don’t be too smart. Avoid producing code for which you need a cheat sheet to write and decipher it. Except if your initials are STL.

Facebooktwittergoogle_plusredditlinkedinFacebooktwittergoogle_plusredditlinkedinby feather

3 Comments

  1. Markus Palcer

    As for the cheat sheets you write yourself while learning:
    To save tree-lives (and time/effort for some of us) it could be helpful to create them digitally and just open your Cheat-Sheet-One-Pager (it shouldn’t be much longer) on a different screen.

    For ppl. who only have one screen: Does anybody know about a program that pops up a Full- or Partial-Screen note on a specified shortcut and hides it again if the shortcut is pressed again?
    I have a single screen setup myself at home, so I’d use that too…

    Reply
    1. Arne Mertz

      I agree, that digital cheat sheets are better for the environment and of course for the tidiness of our desks. However I feel I learn things even better if I write them by hand instead of typing them. I am still thinking about getting a tablet with handwriting recognition – less paper, better learning and even the second screen problem is solved – at least for the cheat sheets. At home I have a cheap 17″ monitor in landscape mode besides the main monitor, so I can launch Stackoverflow, online references or whatever else I need without reducing the available space for the IDE.

      Reply

  2. Hey, great post! You gave those cheat sheets so much thought 😀 Having used them in the past with various degrees of success, I must agree with you on some points. Sometimes cheat sheets are not worth the effort.
    Part of the process of becoming the great developer is to let your thoughts flow and to improvise. You can and you should go back to the things you did before and just acknowledge your mistakes and correct them.
    That is my five cents. Great job starting the blog, stay geeky.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *