DEV Community

loading...

Discussion on: Stop Using "data" as a Variable Name

Collapse
aedanobrien profile image
Aedan

While working on smaller scripts or just scribbling for yourself, I always use i, however once you work on a massive project with 1000s of lines of codes where there are multiple loops and multidimensional arrays going on, and they use i, x, z etc. it gets so confusing. It honestly never hurts to write out a word like accountIndex. It's simply good practice that has no real downside. The argument that it takes longer to write accountIndex than just i is true, however with IDEs having autocomplete this isn't a real issue. Even when writing it manually, it takes maybe 1-2 seconds to write accountIndex. While it might cost you 1-2 seconds now, you'll easily make up for it down the road when you go over that code weeks later and you immediately know what accountIndex refers to, rather than seeing the i for the 50th time. Even just scrolling through the code while working on it makes it so much more visible, saving you seconds here and there.