Face palm/efficient code writing lesson

Face palm/efficient code writing lesson
0

#1

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:


#2

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


#3

This happens on a daily basis… so every day LOL


#4

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


#5

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

then you aren’t learning.


#6

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:


#7

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.


#8

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

#9

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

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