Anyone else ever spend a lot of time writing a huge chunk of code just to realize they could have did it in about half the time using a different method?
Today, I spent several hours trying to make a combo of if statements through an array in JavaScript just to realize I would have made a lot simpler and saved a lot of time using an object type variable instead. Now I have to take a break and rethink my life.
I have been learning different languages for almost a decade now, just for fun, not like proper coding stuff, but the past month I have started working on it very seriously, now I feel whatever I used to do earlier was total nonsense.
Though I think there is something to be said for the brute-force method, especially when just getting started. Otherwise you won’t know what not to do.
I think every programmer has experienced something similar.
// don't do this
if (my.code < others.code) {
assert('I am a failure'); // this is a bad habit, don't think like this.
}
// instead do this
if ( my.code.today() > my.code.previous() ) {
assert(" I am improving. Yay! ")
}