Learning Progress

First post in March… how is it already March!?

I noticed that I tend to drift between the aspects of my learning, devoting most of my attention to one branch at a time. Sometimes I blog a lot, sometimes I code a lot, and other times I “hit the books” a lot. Usually the increased focus on one branch leads to less time spent on the others. I am trying to find a good balance, because all three of those activities help me learn.

I enjoy talking about programming and about learning programming. The social aspects keep me motivated. Exchanging stories and ideas with others who are at various stages of learning to program helps me through the rough patches. Also, getting my ideas out, “on paper,” or in a screencast or video, helps me understand those topics better. Figuring out how to explain something forces me to look at it from another perspective, and almost always it affords me a much better grasp on the subject.

Actually sitting down and writing code seems like the best way to learn, on the surface. I can get too caught up in it though and instead of learning anything about the language or the design, I just fall back on the three or four simple concepts I know and plug away. It’s not a totally bad thing, but I need to keep pushing myself forward. I have been learning a lot of advanced techniques, I just have to force myself to start using them. Lambdas and closures and currying and all of the beautiful things about first class functions, all that stuff is rolling around in my head. The sooner I put it in my codebase, the sooner I can really understand it.

For me, “hitting the books” covers actually reading books, as well as perusing documentation and other people’s code, and especially, it means things like freeCodeCamp, Codecademy and Code School. In the last week or so, I revisited the level 1 Angular course at Code School (give it a shot, that class and several others are free) and then used the momentum to finish their just-released level 2 Angular course. I also jumped back into their JavaScript courses. I had stalled out midway through level 3. It is some pretty heady stuff, but I realized that I shouldn’t back off every time something gets tough. So, last night at about 10:30 PM, I finished the last exercise with some fun prototyping tricks.

My friend Chris Gomez pointed me at an article by Eric Elliot that shines some light on a few ways JavaScript really gets it right. It’s an interesting article that everyone learning to program, for web especially, should probably read. I realized that I own his book, “Programming JavaScript Applications,” and so, after reading the article, I cracked the book open and dove in. It is definitely not beginner level reading, but it isn’t so advanced as to be unreachable. I’ve only been doing this for a few months, and although some of the concepts are still not totally transparent, he does a great job of explaining everything. It also dispenses with the (boring) beginner stuff that you’ve probably read in the first three chapters of every other JavaScript text you’ve looked at. He is concise and knowledgeable, and his style is approachable and very readable. I have a feeling this is going to be a great reference book for me while I incorporate “real” programming methods into my repertoire.

Next up, I want to try the Best Practices course at Code School and jump back into the challenges at freeCodeCamp. I also want to continue my series on Test-Driven Development and finish up my blackjack game. I hope everyone has a productive and happy March!

Advertisements

Leaps and Bounds

As I progressed through Code School’s free lessons, I noticed my grasp of the concepts involved was becoming more and more second nature. I decided to sign up, and at the purchase screen I realized they were giving me a heavily discounted first month, bonus! This began a whirlwind week of learning, as I devoured courses on JavaScript, Git, and a plethora of front-end goodies. I’ve probably picked up more intermediate and advanced skills in that week than in all of my previous learning. Now when I read Eloquent JavaScript and other JS books, the concepts actually make sense. I can read the code snippets and understand what is going to happen. It’s a great feeling.

That isn’t to say that everything sticks. If I don’t reinforce the learning, either by practical use or by taking notes, it gets rusty quickly. Sadly, it’s a silent process. I don’t feel the knowledge dropping away in chunks. I just notice it when I type some Git command and get back an error of some type. After this happened a few times, I knew that just (somewhat) passively absorbing the lessons wasn’t going to cut it, so now I have notebooks covered in my barely legible scrawl. It’s helping quite a bit.

I feel like I haven’t written a lick of code in a while either. I know I’ve had both WebStorm and Visual studio open, with code loaded, several times in the last two weeks. However, I don’t think I’ve done more than look in that entire period. That needs to change. I want to get back to the backgammon game and close up the issues left that make it an incomplete game. I need to work on the couple other programming projects I have going on in the background. Hopefully I can use all of my fancy learning to help me write cleaner code, quicker.

I also want to say thanks to the Code School teachers/professors, especially Gregg Pollack, Alyssa Nicoll and Jason Millhouse. They are quickly becoming the voices of JavaScript in my head.

Small Steps

I would like to be posting (at least) three times per week, and I’m trying to make that happen. Sometimes though, my life is just too chaotic. I don’t think I have talked about my personal life much, if at all. During the day, I am a mild-mannered stay-at-home dad of two beautiful but rambunctious children. Occasionally that day stretches into the evening. Parenting is a complex topic that I could go on and on about, but it’s, um… out of scope for this blog. The short version is, it is a wonderful experience that leaves me feeling scatterbrained and exhausted some days, and it’s part of the reason why I can’t always get a post up.

That said, I am still working and learning and doing programming-type things. Andrea’s post yesterday got me to check out even more online resources for the burgeoning developer. I jumped right into freeCodeCamp, and have completed a few of the challenges. I tend to need a lot of review of topics, and like Andrea, I find doing the same exercises over and over can be a little brain-numbing (and counter-productive).

When I finally got a relatively quiet block of time, I decided to work on my backgammon game a bit. I had identified a task that I thought I could get through quickly.  It picks up right where my last post left off, with my rollDice function. Last time, I managed to get the dice to change color properly, but the game wasn’t actually choosing a starting player, that was hard-coded to be the “black” player and the game just moved on from there. I figured it was time to change that!

Here is what it looked like when I started:

rollDice

Actually, there was an iteration before that. One that just rolled the dice and was missing the if (first) loop. Knowing how I ended up structuring the function, I can already see a problem with what I had above. Two (maybe more?) problems actually. It is already becoming a messy bit of code. I don’t have all the lingo and philosophy down, so I can’t say what exactly bothers me about functions getting larger and more packed. Maybe I want more “abstraction” or “encapsulation” or some other concept that hasn’t osmotically entered my lexicon. But, you’ll see, it gets messier and cleaner.

I knew I needed to compare the dice and select a winner. Sounds simple. I’ve got the dice, do a comparison, pick the winner, change the window dressing, done! interRollDice

This is the messier phase. Less readable. Crammed in a comparison. Remembered I needed to reject a roll of doubles. Tacked that on. You can tell I was running on pure horsepower by the “&&” in that if statement. I can’t even remember if this worked. I went through one version that did the comparison but through sloppy syntax, it just made every roll a “white” win. Sometimes I work way harder than I need to. After a few deep breaths and a snack, I saw a better way. Better, in this case, meaning more readable. It’s possible that what I did next was actually a step backward, but I’m knew enough not to know any better!

diceRollerSmarter

I realized that what I was trying to do still fit under the mantle of the “first roll” and so I nested it into the already existing if (first) loop. I then slammed the check for a double roll into the existing dice comparison loop. I keep reading about recursion and so I wanted to try that. (I hear it makes your code more impressive!). I changed the passed argument from “1” to “true” to make it more explicit. The best part, it works! I think. I really need to start using some type of testing so I can say, “no, really, it works!” but for now I have yet to run into doubles on a first roll, so it seems to be working.

I can’t actually say how long that all took me, I should start keeping track, that would be a useful statistic. It probably took me longer than it should have, but that’s okay. I’m one step closer to finished. I am hoping to wrap this up and submit it to the One Game A Month challenge. It’s almost playable at this point, I really just need to set up the bearing-off stage and figure out how to know when someone has won. I’d also like to clean up the presentation a little. “Just a few more hours” of coding, really!

Ready, set, go!

There are a lot of ways to learn to code. There are a lot of ways to actually write code. There are a lot of things to think about. It can be… it is overwhelming. “Start there,” was my mandate, and with that in mind, I decided I need to quickly find the lowest resistance approaches.

I knew immediately that books, as a first step, were not going to work. There are just too many, with varying levels of prior experience assumed and no quick and easy way to determine if they even offered what I would need. I would soon circle back to this avenue, but for now I knew it would only bog me down.

Formal education. I bring this up even though by this stage I had already discarded it as a method for me because I think that under other circumstances, this would have been more attractive. That is probably a topic for later discussion, but my timeline ruled this out too.

The most attractive path for me, then, was informal education. For this I turned to the internet. One website in particular came up repeatedly. Codecademy. It turns out, this is where I would start. I should give a special mention for another website that shares a lot of the same features of Codecademy, and that primed me to learn in this fashion. Anyone who has investigated interactive, gamified learning on the internet has surely run into Khan Academy.

A few years ago, a friend asked me to help her son with his math homework. I figured I could handle pre-algebra, even though it has been a long time since I cracked open a math textbook. But just in case, I started looking for online resources. If nothing else, I could crib the methods to help me teach the material. That led me to Khan Academy, and I raced through the material, eventually progressing further than I ever got at school. I never did finish the lessons in Linear Algebra (sorry Matt, I really wanted to be able to help!), but Khan Academy is still one of my most used bookmarks.

Codecademy follows a similar model. Focused lessons with a gradual progression, and rewarding badges and challenges. Compared to Khan Academy, Codecademy is almost Spartan, but that is actually one of its major plusses. There aren’t a lot of distractions or roadblocks or hurdles. Sign up and start learning. The front page emphasizes a somewhat holistic approach to learning, with the more general Web Developer lessons at the top and then language specific courses below.

For me, Codecademy was the perfect introduction to Web Development. Self-paced, with easy navigation and just enough positive reinforcement to keep me motivated without being patronizing or cloying. I spent around three weeks sprinting through lessons whenever I had the time. Pretty soon I was feeling comfortable with the three main “languages” in their core web dev section; HTML, CSS and JavaScript. Not an expert, by any means. In fact, probably just enough knowledge to be dangerous, but I knew that I still didn’t know enough to know what I didn’t know!

It was time for the next step, but once again, I wasn’t sure what that step should be. Books have been a big part of my life since early childhood. The feel of holding a book and flipping through the pages is a very relaxing and comforting act for me. I still didn’t know how to pick and choose, and I didn’t need a dozen books of varying usefulness sitting on my shelves. And that’s how I ended up in a bookstore, monopolizing the twelve feet or so of programming shelf space. Once again, however, I realized that I still didn’t know what to look for, but I at least felt like I was getting closer…

Next time, I’ll talk about finding the right tools and, big surprise, the right books.