K.I.S.S. – Keep It Simple, Stupid!

A lot of people find mnemonics and acronyms really helpful, and I remember using them in school to remember the order of steps in tasks, or to recall a list.

I have a grand total of two in my regular repertoire. The first helps me remember the order of the planets (Many Very Early Monkeys Just Sat Up Near Pluto)- not super useful in my day-to-day, but it’s helped me out in a pub quiz once or twice! The second, the title acronym of this post : KISS (Keep It Simple, Stupid) and I’ve been thinking about that one a few times over the past couple of days!

I’ve been working through Eloquent JavaScript– not making the speediest progress, but there’s an awful lot going on in my house this week, so I’m just happy to still be making progress full stop. I read through the Introduction and first chapter, and found the first exercises at the end of the second chapter, Program Structure. There were three exercises, and I managed the first two without too much trouble, but I got really frustrated with the third exercise. The challenge was to log a checkerboard of hash symbols and spaces to the console, which you could adjust the size of by changing a variable.

I was going for something like this:

# # # 
 # # #
# # # 
 # # #

I was definitely just making things too complicated. At the peak of my frustration I had two if/else loops nesting inside of a for and a while loop.To say it was getting a bit messy would be an understatement! I kept writing and deleting lines, but just kept making it worse, so in the end I had to look at the solution code. I started by looking at the first two lines of code, and working my way through it from there. It was much cleaner code than what I’d been writing, and adhered to an acronym I’ve been reading a lot about lately : DRY (Don’t Repeat Yourself.) I spent [and sadly, I’m not exaggerating here] hours [plural] working myself up, making my code more and more complicated, when it really shouldn’t have been- I mean, come on, it was the third exercise of the whole course!

I’m working on another set of exercises for the course, and now I’ve got two acronyms in mind while thinking about ways to write the code for these ones : DRY, and KISS.

7 thoughts on “K.I.S.S. – Keep It Simple, Stupid!

  1. Oh man I can relate to this. I’ve spent so many hours just trying to get things working by adding more and more code. I’ve realised that at some point you just have to step away from the it all and do something else.

    Liked by 1 person

    • Thank! Good to hear someone’s in the same boat! I’m getting better at seeing when it’s just getting a bit too complicated, and erasing part of [or all of!] the code I’ve been working on.

      Liked by 1 person

      • Awesome! It is definitely a skill to be able to cut your losses and scrap your work. I know I definitely struggle with it. The code I write is like my baby, I spend so much time crafting it, I don’t want to throw it away. Good luck with it and let me know if you want some motivational pep talks!

        Liked by 1 person

    • The thing that I found the hardest was not making the exercises too complicated. If you’ve done pretty much ANY reading/studying before you’ll probably do that too. My best strategy so far has been to write the code [or a few versions if it, if I can think of different ways to do it!] and then to look at the solution and compare it to what I’ve written. I think I spent just over a full day working on the exercises from the first chapter, but all sorts of stuff going on in my house right now, so I’d say honestly, about four hours [most of that spent banging my head against the wall!] You should blog about it too- I’ll be cheering you on! 🙂

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s