When people start programming, the focus is on getting a program to run – writing code that the computer can read. However, when you get into your professional programming career, the focus needs to be on writing code that other programmers can read.
Yes, the program needs to run without crashing and produce the correct results. But business programs can have long lives.
I’ve repeatedly worked on programs that were written more than ten years prior, and whose developers left the company years ago. The company has been running the program for years and now need to make a change to it.
If another developer can’t understand what your program is doing, they are going to have a difficult time fixing bugs or adding new features.
Here’s something to keep in mind: you may be the programmer who needs to make the change.
Your code might be easy for you to understand today. But will you be able to understand it when you haven’t looked at it in months or years. Will you remember how it works when you’ve developed dozens of other programs since writing it?
I’ll write more about how to make your code easier to understand in a future section but keep this in mind when writing your programs. Don’t try to be clever. Make your class, variable, and property names obvious. Write small functions that do one thing.
There’s a saying, “Write your programs as if the person who will be supporting them is a violent axe-murderer who knows your home address.” Don’t give that imaginary developer a reason to be angry with you.