Tuesday, March 10, 2015

2 tools to help you learn how to code.

I thought I would share with you the hardest challenge for me personally, about learning how to code and how I overcame it.  I want to encourage beginners who are about to give up coding, because they feel like they just don't "get it".  The truth is, I couldn't either, I felt extremely non gifted when it came to coding.

The hardest part about learning how to code is not learning the syntax, Html or Css.  The hardest part about learning to code is the actual "coding logic".  Growing up I struggled with Algebra and abstraction like you wouldn't believe, I thought I was dumb.  A lot of math wizards get abstraction much quicker than I do.  For me I have to keep struggling and struggling until I finally get the concept to "click" in my brain.  The thing is not to give up, don't make yourself feel bad that you aren't naturally "gifted" as a coder.

3 months after I started learning to code, I couldn't solve a single problem on the easy coderbyte challenges.  Hours of trying, didn't help, I didn't understand the concept of a method.  I didn't understand how different data structures got to use different methods.  Thankfully I am more stubborn than dumb and didn't quit.  Days went by, still I didn't understand.  What helped me to break out of the rut, was realizing that I only really needed 2 coding skills to solve most of the coding challenges.

DISCLAIMER:  This is not about writing beautiful code.  This is about improving your coding abilities enough to solve basic coding challenges.  Pretty comes later :-)

I realized that the power of coding was in knowing how to use 2 things ( statements ) in a language:

1) If else statements
2) for loops

Once I realized that I really only needed to figure out how to use those 2 statements.  I gained a lot more confidence.  Now whenever thoughts crept into my head like:

"Maybe you're just dumb" 


"Maybe you aren't meant to learn how to code"

I would focus on learning how to understand for loops better.  Since I am a very visual learner, I would take little pieces of paper and write a variable name on them.  I would them make another piece of paper and call it array.  I would then manually try to walk through what was happening with the data instead of trying to keep it all in my head.

The good news is after a week or so of doing this, I started to get it.  Finally it clicked and I realized that I was way over thinking how loops work.  Loops aren't magic, they are actually really simple.  Even when you throw in a double nested loop, I would simplly print out what was happening at each step of the loop.

Yes, nested loops aren't the best.  Yes you probably should use a for each iterator instead of a for loop.  For me though, once I understood how loops work, I realized how much I could do with just a simple for loop and some if else statements.

Whenever I had some code logic that wasn't acting as I thought it should I would just look at this:

That's all I would do.  I slowly started solving coding challenges.  I started to gain a little more confidence.  Yes my code looked like crap, but I wasn't giving up on learning how to code.

After focusing on using only 2 simple statements to solve coding challenges.  I decided not to stress about feeling the need to use more complicated data structures.  Instead I tried solving as many problems as I could using only arrays.  I didn't care what the problem was, I first tried to solve it using an array.

Dumb I know, but for me that's how I started to realize that I did in fact need more of what the language had to offer.  Instead of reading a massive book and freaking out about: linked lists, hash maps, dictionaries etc.  My mind was now eager to see what else in the language could help me solve a coding challenge easier.

Then I discovered underscore.js, lodash.js, and recently ramda.js libraries.  How do you use a library?  How do you use a REPL to run Javascript?  What is a REPL?  Coding is no longer scary to me, it's still hard, but fun :-)

I strongly encourage you, whether you've been painting houses your whole life, are a CS college drop out, or in my case were shoeing horses for 8 years.  Don't compare yourself to others, you can learn this stuff.  Learn in such a way that your mind looks forward to solving coding challenges instead of dreading them.

I'm on step 6 of 6,327 steps to becoming a senior developer one day, but that's ok!  Progress is progress, my motto is: keep it fun, never give up and you will learn how to code!

Keep coding peeps!

P.S.  Let me know if you'd like more "how to" style blog posts.  I have lots to write, but I want to write things that will benefit people who are starting out on the path of learning how to code.  Comment below or email me :-)