Chris Zetter

The Name of the Class

Spoiler alert: This post discusses the universe in the book ‘The Name of the Wind’ which is gradually explained throughout the book.

It’s not often that reading a fantasy novel makes you think of problems in Software Engineering.

The Name of the Wind1 is set in a world where magic exists. One kind of magic that is possible is to have control over something (like the wind) by naming it. Towards the end of the book a character describes the power of names:

“Words are pale shadows of forgotten names. As names have power, words have power. Words can light fires in the minds of men. Words can wring tears from the hardest hearts. There are seven words that will make a person love you. There are ten words that will break a strong man's will. But a word is nothing but a painting of a fire. A name is the fire itself.”

Excerpt from ‘The Name of the Wind’, Chapter 86, by Patrick Rothfuss.

Finding the right name for a class, method or variable within software can give you power too. It gives you the power to read and discuss the code naturally without doing additional translation of concepts in your head. If what you are trying to name isn’t a well defined concept, thinking about the name gives you the power to see the responsibilities of a class, making it easier to spot code which could be re-architected or refactored.

So what is a good name? Tim Ottinger wrote Ottinger’s Rules for Variable and Class Naming which is a list of rules to follow for good names. Each rule is well explained with examples of code and the benefits of following it. I don’t think anything has been written since that can help to give you more control over your code.

  1. ‘The Name of The Wind’ is the first book in Patrick Rothfuss’ ‘The Kingkiller Chronicle’ trilogy. I really enjoyed reading it and am about to start the second. I will try to pace myself as the third book may not be released for a while

Read more by me, follow me on Mastodon or subscribe.