Face palm/efficient code writing lesson

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.

(haha just kidding, its not that dramatic)

Definitely need to plan better next time though. :stuck_out_tongue_winking_eye:


A good way to learn is to make inefficient mistakes… but only if you recognize those inefficient mistakes. :smiley:

1 Like

This happens on a daily basis… so every day LOL

Yup, many of times. The solution: don’t rush to coding and think of different possible solutions before implementing.

If you aren’t regularly feeling like past you was an idiot that didn’t know anything,

then you aren’t learning.

That’s how we learn mate. :slight_smile:

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. :smiley:

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! ") 

I second that. Could’t have expressed it better.

Console.writeLine("Here's your cookie"); //Enjoy!
1 Like