Naming your variables properly

Always use meaningful names for storing your variables. If you don't do that, six months down the line, you will be sad. I'm going to exaggerate here a little bit to make a point. I will name a variable as shown in the following code:

public bool theBearMakesBigPottyInTheWoods = true;

That's a descriptive name. In other words, you know what it means by just reading the variable, and so ten years from now when you look at that name, you'll know exactly what it means. Now suppose instead of theBearMakesBigPottyInTheWoods, I had named this variable as shown in the following code:

public bool potty = true;

Sure, you know what potty is, but would you know that it referred to a bear making a big potty in the woods? I know ...

Get Learning C# by Developing Games with Unity 3D Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.