DEV Community

Discussion on: Why should one use multiple Variables when you could store everything in an array?

Collapse
 
kspeakman profile image
Kasey Speakman • Edited

Readable vs Writable.

When you save something into the most concise container possible, you have optimized it for writing. You then pay the cost later of interpreting it. Fast forward a year, and someone else is reading the code. They have to reverse engineer what each piece is meant to represent based on its usage.

If you label what each piece means and use them in commonly-understood ways, there is less work for the future reader of the code to gain understanding of what the code does. However, it may also mean there are more lines to change when the logic needs to change. It is optimized for reading, not writing.

The skill that comes with experience in programming is how to strike the right balance (or which side to lean toward) in a given situation.