5 ms·
Ask HN: Do you think ahead when programming?
I always find myself forgetting necessary variables when programming. For example, when I am summing the numbers between 1 and 5, I might remember to start the for loop
for (int i = 1; i <= 5; i++) {
}
but then I'll realize I forgot to initialize a counter, so I'll go back up and add int counter = 0 at the top.
To combat this issue, I've been visualizing code in the future while writing the current code. This has been making my brain sharper and improving my programming. However, no one talks about it. Thoughts?
- luxurytent 5y agoWithout thinking ahead, I'm not considering the scale of technical debt I may introduce with my change.
- ZhangSWEFAANG 5y agoCan you elaborate on this? I'm not sure what you mean.
- tyingq 5y agoAn IDE can show you stuff like that. Visual Studio underlines uninitialized variables with a squiggly line for me.
- thagerty 5y agoDepends on what you mean by 'thinking ahead.' Do kids make flow charts anymore? How about writing code out by hand before typing it in? These exercises used to be considered normal 'thinking ahead.' Sometimes necessitated by resource constraints, other times just a rough draft practice, some type of forethought is a good way to train your mind to do the work, instead of just reacting to errors.