Week 4: Losing Power

Another roller coaster week. Worst points: Someone took my laptop charger while I was in lecture, my week 3 assessment was not my finest point, and I miss my cats something desperately. Best points: I worked with my two favorite pair-partners again because I couldn’t handle this week otherwise, I had an awesome girl’s lunch today with 4/5ths of the junior class women (there are 5 of us total), and I made a node.js server!

So I definitely felt my first crazy/not enough sleep/irrational emotions. When my power cord was jacked a couple of days ago I was devastated. In retrospect, I think I’m a little tired and cranky and, like I said previously, I am in desperate need of some kitty cuddle time. I’ve  been in California now for over a month and I still love it, but it’s definitely getting more difficult. There are times I wish I could just zen out and I only really get that on the trains or at midnight in the dark when I should be sleeping so I can wake up and do it all again the next morning at 6am to catch my train.

I have never been more excited/motivated to get up in the morning in my life and I can’t get to sleep at night because code and other things are running through my head and along the way something had to give. I’ve discovered that when something has to give it’s my emotional stability. My actual sprints were amazeballs, especially since I had awesome pairs (Sara and Andy, respectively) for my Backbone and Node.js sprints. But in my quiet moments or while I was working solo the doubt and sadness came back.

So I did what I always do when I’m sad – I talked to my parents, a lot. I called them while waiting for the train, I called them sitting on the couch in the Hack Reactor lobby during lunch, and I called them while I drove home at 9pm every night. My dad especially is awesome at making me feel better. He’s always so proud of me and he’s always  interested in what I’m doing. It’s hard sometimes here, but I have an amazing support system both in Oregon and here. My platonic life partner Ava and her husband John have been my rocks in more ways than one. My new awesome friends at Hack Reactor, especially the ladies of the Nov ’13 cohort have been awesome to get to know. And I know all my family, friend, and former coworkers back in Oregon love me and miss me as much or more than I love and miss them.

Thinking about it and even writing about it has helped as well. Getting it off my chest makes it so I can breathe again. So I guess I just want to say, I love you all. Thank you for dealing with me! I really am happy even if I didn’t sound it sometimes this week. If I don’t just sleep all of tomorrow/spend my day in San Jose with other awesome people I love to pieces, I’m going to try to post a non-emotional/tired/whiny post, but honestly, I want to keep this blog real. For me as well as for you and this what has dominated my brain this week.

Inside My Head: Learning JavaScript

I have had a very productive weekend so far (and it’s only Saturday!). I am spending some of my day today going back through my easy Coderbyte solutions and cleaning most of them up. I will also be adding in comments for most of the lines explaining my logic. So a lot of the files will look like this:

 function FirstReverse(str) { 
   return str.split("")  //splits the string into an array of characters 
             .reverse()  //reverses the array 
             .join("");  //joins the array back into a string, with no space between the characters 
 } 

This is actually a lot of fun for me. Now that we’re getting into more abstract concepts like MVCs and servers it’s nice to just go back and power through some JavaScript code and understand exactly what it’s doing.

As always, you can find my coderbyte solutions on GitHub (I will be posting updates to it throughout the day), but I feel like I need to start adding a caveat, because of the amount of people who have said they found my blog looking for coderbyte solutions. Just staring at my code isn’t going to make you understand JavaScript. You need to do it for yourself. If you’re brand new to JavaScript, just seeing the cool tricks is not going to make you a programmer. I really recommend things like Udacity, Codecademy and other sites that talk about the fundamentals of comp sci/programming.

Time Complexity in Algorithms

Time complexity is a useful concept in programming. It’s essential for job interviews, but beyond that to really be a good programmer you need to know how cumbersome your algorithm is going to be. For 10 items, something that takes 2 seconds per item is only 20 seconds, but what if you have a million items?

In general, time complexity is measured by how long it takes a number of items (n) to be processed. It is the relationship between the number of things you have to do and the work to be done. Something that takes the same amount of time no matter have much of it you have to do, would be constant time. If I had 10 items or 1 million it would only take me 2 seconds to process. On another extreme is something called the handshake problem. If you only have two people in a room they only have to shake one another’s hands (one handshake). If you have 10 people, they each shake 9 other hands (55 handshakes total, we’ll get to the math in a moment). This is quadratic time.

Here’s a visual of the common programming time complexities:

Time complexities!

 

Lets start with constant time again. In programming, constant time is like deciding whether a number is even or odd:

 n % 2 = ? 

This is just one expression. You run and you’re done. It’s always going to take a certain amount of time, no matter what n you give it. In big O notation we would write this as O(1).

Next, my favorite, as far as understanding goes. Linear time. In programming, linear time, is like running through a loop of n numbers and doing something.

 for( var i = 0; i < n; i++ ){
   do something..
 }

The more things (‘n’s) you have, the longer the algorithm is going to take. It’s a 1:1 ratio. If 1 thing takes 1 second, 2 things are going to take 2 seconds. This is O(n).

Quadratic time is worse than linear time. It’s like the handshake problem or in programming terms a for loop within a for loop. For each n we need to run through all the numbers 1 through n.

 for( var i = 0; i < n; i++ ){
   for( var j = 0; j < n; j++ ){
     do something..
   }
 }

Each n thing is done n times. This is n * n or in big O terms O(n2).

Logarithmic time is all kinds of magic. It tapers off to a near constant for larger ‘n’s. This is possible because of the magic of halves. In a binary search tree there are only two options to descend, left (options lower than the current value) or right (options higher than the current value). Either choice will cut off roughly half of all the possible values. On the next level, you have the same choice, either you’ve found your value, or you go left or right, halving your options again.

 while ( low <= high ) {
   var mid = ( low + high ) / 2;
   if ( target < list[mid] ){
     var high = mid - 1;    
   } else if ( target > list[mid] ){
     var low = mid + 1;
   } else { break; }
 }

If you’re constantly halving the amount of things you have to check, eventually you hit a roughly constant time for an n search. This is O(log n).

This post has been brought to you by a forum post on time complexity, bits and pieces of the wiki article on time complexity, and this inspirational code class ad featuring my lead instructor from his Twitter days.

Week 3 – Less Work, More… Work?

School-wise, this week was very, very short. Today is Thanksgiving and I’m almost a little shocked that we got it off (although many of my peers are spending their day at the school if the emails about keys and door opening flying back and forth are a good reference). Because of the shortness I was thrown a bit off guard on Monday when I realized that it was time for our 3rd assessment already! This is week three! It feels simultaneously like I’ve been here for days and for years. The assessment went well and I actually remembered all my things from the previous week without too much panic. I did have a hilarious nightmare afterward that involved me being forced to code a merge sort algorithm using a pencil and a very limited amount of paper and my lead instructor yelling at me for my terrible handwriting (this is why I love computers! I have terrible penmanship).

Because of the short week we basically just went straight into Backbone.js this week, which for my non-coding followers is a JavaScript library that allows you to structure your app cleanly by dividing the work that must be done into the actual data “models” and the way you represent that data to individuals “views”. This concept is what’s called an MVC, which is one of those trendy/useful buzzwords you hear a lot in coding. Anyway, it’s what we did in class this week and I plan on working on it a bunch over my long weekend.

Unfortunately because this is the longest break I have besides solo project time during Christmas break I think I’ve put more on my to-do list than is physically possible (especially since I promised my platonic life partner Ava I would help her with her Hackbright project too). Lets run down what I have on my list:

  • Review algorithm time complexity (Big O notation)
  • Practice recursive problems
  • Make business cards:
    Personal business cards of awesome
  • Work on my Backbone project (we are working on it through next Tuesday, but I want to tackle some of the extra credit)
  • Redo/refactor some of my Coderbytes code – I’ve learned a bunch, I can probably do better
  • Research getting involved in some open source stuff/get some pull requests in to bigger projects
  • Maybe try learning Ruby on Rails (we might lose out on the Ruby on Rails sprint because of the timeline of holidays)

So yeah, I’m probably a crazy person. Today I will eat and hang out with friends and be merry though. Tonight I will allow the code to creep its way to the front of my brain again. I also plan on writing a more technical article on time complexity sometime this weekend if I can wrap my brain more fully around it so I can pass along the tips I find.

Week 2 – Programmers Do It Algorithmically

I have less pretty pictures for you this week. The most I saw of the sunshine looked similar to this:

View from the 8th floor

At least it was sunshine. It “rained” for like a minute one day and the umbrellas came out en masse. I was perfectly happy in a hoodie, but I definitely felt like an outsider. I might need to buy an umbrella, this whole trying to not look like a tourist thing is harder than I thought. Although I’ve had more people ask me for directions this week than I ever have in my life combined so I think the hair and the nose piercing are good SF camouflage.

This week was a teensy bit rollercoastery for me. We started out with a fairly easy CSS/fun jQuery tricks problem and then tackled a pretty epic sprint on the N-Queens problem. N-queens is the idea that you need to place n (a number) of chess queens on an nxn chess board so that none of the queens can attack any other queen. I think they’ve only solved it up to 27 ( and that was people from Hack Reactor). I got a little flustered with that one as algorithms were never my strong suit before this (it’s why I got the “conditionally acceptance” at App Academy – thank god, might I add). I think though I’m just being too hard on myself. Not every software engineer deals with something as crazy as the n-queens problem on an everyday basis. Our more traditional daily toy problems (similar to tech interview questions) are fairly straight forward and I can code a bubble sort algorithm in about 5 minutes (maybe 10 with one hand tied behind my back).

I think that’s what Hack Reactor has done for me more than anything else. It’s made me accept my flaws, but know that everyone has them and there is always more to learn. I’m a good intuitive coder, but I’m no good with the lingo of it. We all are here to learn to become great coders Software Engineers.

Short post this week, sorry. I have dinner with friends to go to and my Sunday is too peaceful and sunny (and full of awesome 50th anniversary Doctor Who) for any more words.

Week 1 – “Hell Week”

This article could easily be subtitled: Glimmering punctua of pure clarity and childlike wonderment. But then I’d be jacking my title from Marcus (our lead instructor/one of Hack Reactor’s co-founders). Hell week (as the instructors affectionately call week one) is semi-officially over and I am more content than I have ever been in my entire life. I will admit that as I got ready and rode the train into the city on Monday morning I had my doubts. Was I cut out for this, would anyone like me, was this program going to be totally not what I expected? Let me tell you my friends, it is more (any adjective is useless here) than I can describe.

On Monday morning I told myself not to be nervous, but the impostor syndrome and general unknown was super strong. The train ride was scary, the solo walk to the building was scary, the first few uncomfortable introductions in the kitchen area where breakfast is served were scary, but I have come to love this sight:

944 Market St

It’s so typical San Francisco. Teeny entryway wedged between a Payless Shoes and a sketchy looking pawn shop. It’s after you step into the elevator, which is typically a little creaky, and emerge on the top floor that the magic starts:

First Impressions

It's JavaScript all the way down

This week has been a blur. We had lectures that ranged from how to be an effective student to the principles of time complexity on different data structures. We implemented our own auto resizing hash tables (well some of us did, me and my excellent partner, Sara, who started out as a blog stalker apparently and ended up being an awesome lady and I’m glad to call her my friend, got through most of the extra credit work and so got to a point where we had to tackle resizing hash tables). We tried valiantly to learn 30ish names while trying to cram in as much computer science as possible (I can proudly say I know the whole junior class – my cohort). We learned the least and most reasonable places to eat and wander during the day and after dark and we all developed what I think will be a pretty awesome camaraderie that will definitely benefit me for years to come.

My life has been completely altered in ways I don’t even know how to quantify yet. We’ve covered computer science concepts in the past week that I learned over the course of a year back in college when I first tried to be a computer science major. The thought scared me at first. When I realized we were covering things I had learned before, I was afraid I would feel the same way about them, like I wasn’t good enough to get through them. That was always my fear in college, that I was just fooling myself and everyone around me.

So I spent at least half of this first week waiting for the other shoe to drop. Technically it did drop, but not in the ways I thought it would. It dropped when I realized that this thing that I can do with my brain and this keyboard is pretty damn amazing. That I am pretty amazing. I can have an off day, my recursion algorithm can go unexpected places and my crafted tests could not pass, but that’s the life of a software engineer. Things don’t just get done by typing out code as fast as your fingers can move, they get done by running into walls, refactoring, researching what other amazing people have done, and bouncing ideas off of your fellow engineers.

To sum up all that wall of text: Life is pretty damn awesome now and there was nothing hellish about this week.

Week 0 Wrapup

I meant to post before today, but the picture I wanted to use in this post wasn’t available yet and I managed to get a cold… Everyone at Hackbright was getting sick and Ava’s husband also got a cold, so I guess my time was nigh. Thankfully Ava’s an amazing nurse (she’s strict though, she won’t even let me have a Diet Coke).

I did have a fun week rest of the week in spite of how I feel today. Thursday we stayed at home and Ava got some awesome work done on her final project and I just played around some more with Angular tutorials and double checked her semi-colons in JavaScript. Thursday night though, was awesome. We did this:

Geek Girls

I got to go to my first ever geek girl dinner! Ava hooked me up and I really hope I can go to more in the future. We went to San Jose to visit CISCO‘s main campus. It was super inspiring and totally pumped me up for next week. Also they had tasty food and gave us T-shirts and I got yelled at by Ava for saying I was a student and not an engineer. I won’t make that mistake again!

Yesterday I trekked through three different transit systems to get back down to San Jose by myself to visit my other bestie and have dinner with her family. We had lots of fun and visited the giant library next to the SJSU campus. She and I share a ridiculous love of reading and I think she just wanted to rub it in that I will have no time to read for a long while.

Hack Reactor starts on Monday and I’ve been drinking tea and sitting around in my pajamas all day in hopes of feeling decent by Monday. Wish me luck!