Code is WORM: Act Accordingly
Write Once. Read Many. The cost of avoiding shortcuts when writing code is far exceeded by the benefits you'll get when reading it.
Write Once. Read Many.
Physical memory devices are designed to optimize for their intended usage. You wouldn't want to use magnetic tape to store and retrieve values in random access memory. Likewise, you wouldn't want to rely on volatile memory that requires a constant supply of power to store financial records for the next several decades.
The same concept applies with programming.
You write code one time, but over the lifetime of a (successful) project, you will read it many times.
That's why it's better to optimize your code for reading, not for writing.
The following tips will help with that:
- Don't Write Clever Code
- Avoid Magic Numbers
- Use Clear Variable Names
- Use Vertical White Space to Group Related Statements
- Use Consistent Indenting
- Keep Routines Small Enough to Fit on a Single Screen Without Scrolling
- Make Wrong Code Look Wrong
Image by Катерина Кучеренко from Pixabay