There are only two hard things in Computer Science: cache invalidation and naming things.
This is a quote attributed to Phil Karlton, a famous Netscape (now, that’s a trip to the past!) developer. It’s, without question, my favorite programming quote. I share it whenever I can (like now!).
On the surface, it seems like only one of those things is hard. That’s cache invalidation. It’s the process of removing invalid data from a cache. If you’ve ever built anything with WordPress object cache, you know that it’s not easy to do at all.
But naming things? Who struggles with that? That seems like the easiest thing in the world. And that’s true in a way. Naming something doesn’t take a lot of effort.
Here, I’ll even name three variables for you! They’re
ninja. You might wonder, “Why did he pick pirate, wizard and ninja as variable names?” No reason. They just sound awesome!
The point of using a silly example like that is to show you that you can name variables anything that you want. It’s not hard to find a name. The hard part is picking a good name. It needs to be clear and mean the same thing to everyone reading.
So what can you do to ensure that you’re naming things as best as you can?