Tuesday, June 21, 2016

Stringing Methods - When and Why

Recently (I'm far too tired right now to think of the actual date), we went through a sprint learning the basics of d3. Really the sprint was meant to be a learning path to understanding documentation with little to no guidance (which is definitely something I'd like to touch on, but in another blog post). But there was something else I learned from that particular sprint, and though it was a minor take away in the scheme of the project, it's something I would like to quickly touch on.

For those of you that don't know - d3 is a JavaScript Library for visual manipulations or representations of data. Basically, it turns data into pictures. That's an over simplification for sure, but for our purposes, that's all you need to know.

If you've ever used jQuery, d3 will look hauntingly familiar to you. The two libraries share many similar methods and are syntactically very close. Both are commonly used to manipulate the DOM (ie, change things on HTML documents/websites) and both are extremely object/method oriented. 

To give you a quick example, let me show you one line of code my partner and I used during the d3 sprint:

Just a quick example of d3. I'll go over very briefly what's going on, but for an in depth look into the mechanics of d3, I would suggest looking through the documentation.



Creating a variable board and setting it equal to the first element the d3 selector finds with a class of 'board'.



Adding an SVG element to the board element. Once again, if you're not familiar, I would suggest a quick google.



Giving the SVG these two attributes. If settings.w and settings.h were both equal to '500px', this would be the same as setting up an HTML element like so: 



But to get to the meat of things, for those of you, like me, with less of a background in Object Oriented Programming, or OOP, this system of stringing together methods may seem rather alien, and more confusing that it needs to be. For one thing, the fact that this piece of code takes up four lines in purely aesthetic. It is the exact same as calling each of these methods one after another on the same line.

But what makes this possible? It seems a really odd idea to the novice OOP engineer to call a method on another method. But to understand what's really going on, we need to look behind the scenes. For simplicity's sake, I'm going to create my own example:




Here, I've created an obj with two keys, name and money, and two methods, earnMoney and spendMoney. If I wanted to add some money to my bank account before spending a little on a snack, it would be relatively easy:



But there's an even simpler way to do this:



The key behind this ability is the return statement. On lines 9 and 14 of my example above, each method returns this, referring to the object the method is attached to. This means that line 18 is returning an object with a name of 'Ryo' and a money value of 125. If we were to simply make a call to myObj in between lines 18 and 19, it would return the same thing.

This is the the main point behind stringing methods. Since line 18 returns the same thing as myObj, we can replace the myObj on line 19 with the code on line 18 (as shown on line 21). We're simply calling the spendMoney method on whatever the code to the left of it returns.

This makes it possible to string together a lot of jQuery's (and d3's) methods, since a good number of them return some element from the DOM, just like using $('.someElement').

But this doesn't mean you can go stringing methods together will nilly! Be sure that you know what the previous method is returning, and if it will interact with the new method the way you're expecting. It's always best to know what you're expecting from your code and what your code is expecting from you. When in doubt, play it safe and apply each method separately.

This is a simple idea, but many people use it without really understanding what's going on in the background (I know I did). Something I'm very swiftly learning is that a lack of knowledge of the behind the scenes workings of your code can often lead to confusion down the road. It's not that you need to understand absolutely everything, but a basic understanding can be the difference between a mediocre programmer and a great one. 

Tuesday, June 14, 2016

Week 2 Day 2

I'm gonna be completely honest with you, peeps. If Hack Reactor hadn't allotted this hour to blogging, and literally forced me to do it, I may have never written in this thing again. I'm exhausted. The first week was an ocean of peaks and troughs, and starting from the somewhat benign first day, it's only gotten more intense from here. It's been a physical and emotional roller coaster, and the idea of taking any of my "free time" to write a blog post is almost sickening. So due apologies if this isn't up to par of the energies of my previous posts.


Now, I'm sure this wouldn't be everyone's experience here. There are bound to be a good number of people in my cohort who are feeling fantastic right now. And honestly, I've been there about 60% of the time. It is an extremely fulfilling roll, that of a student at HRRB. The victories taste that much sweeter for the struggle it took to get there. But for me, it's been a little rougher than I care to admit.



I coasted my way through public school. From the time I was very young, I never had trouble with tests. I never had test anxiety. I always scored in the highest percentile, though usually second vs first. But because of this, I never really had to put any effort into it. I can't remember the last time I studied for a test (and that's saying something considering I can still remember most of middle school). I've had the mindset that as long as I pay a bit of attention in class, I'll score just fine.



But, as most of you have guessed, Hack Reactor isn't that easy. I knew that when I came into the program. But old habits die hard, and it's been increasingly difficult to get it across to myself that just listening to the lectures once is not going to get me the most out of this class. I'm stubborn at heart, no point in denying it, and it's hurting me here.



Not that I'm not learning. Slowly, bit by bit, I'm coming to an understanding with myself. I just have to keep reminding myself that it is beyond worth it in the end to avoid the utter embarrassments my self assessments have been.



Self assessments are Hack Reactor's version of tests, but they're geared towards helping you rather than being a true representation of how much you know. Going into my first one at the end of week 1, covering the prep course work, I was over confident. As soon as I saw what the test was on (underbar and recursion), I felt more than duly confident. I flew through the exercise, determined to finish first, as was my norm. And I did. I finished 12 minutes into an hour long session. I checked my answers against the syntax checker they had provided. And I turned it in without a second glance.



I had done everything right, as far as I was concerned in that moment. My code was clear and easy to read. I had written out all my pseudocode and descriptions. I couldn't have done a thing wrong.



And of course I was wrong about that. I had left out something so ridiculously stupid it was silly. I had just forgotten to pass a new argument into the recursive function when I called it. But that was all that was needed. Obviously, my code didn't work. But I hadn't bothered to test it myself.



The embarrassment was bad, but not quite so bad as the week one assessment.



I learned pretty quick after that to write my own tests. And there was a real sense of accomplishment, honestly a genuine joy, in creating mocha tests, seeing them fail, and then watching them pass. Something so tiny as a little green checkmark should not had made me as happy as that did. But it did.



And it's those moments that have been keeping me going. I think it was Marcus Phillips that said it in one of lectures, but programming is 95% failure, and trying to figure out why you failed. But that little 5% of success can make the whole seem that much brighter, can fill you with the kind of joy that should only come from roller coasters or winning the lottery. That's what's pushed me through the hard bits, the frustrating parts, and the worst bits - the embarrassing parts. They're addicting. A bit like chocolate. Or cocaine.



The second assessment was the hardest bit for me. It tested me more than any of the sprint frustration could. It was probably my stubbornness that really did me in, but there was also some simple lack of knowledge and experience. I should have studied. The ideas weren't all that hard. But I started with the hardest question in my hubris and refused to move on when I couldn't get it. In the end, I completed maybe 70% of the sprint, and of that, I only felt confidant in about 40%. And no, I didn't finish that hard question.



I'm leaving on a good note tonight, though. We've been on a two day sprint called Subclass Dance Party that was meant to help hammer home pseudoclassical classes and subclasses. It was a steep learning curve, and there was definitely some struggle in it, but there were also some awesome moments of success. We used sprites, made randomized party parrot dancers, made random people chase each other around the dance floor, and, best of all, made a Batman and Joker, adding fun text bits and audio snippets. It was satisfying in a way that's hard to explain. Having an idea in your head and turning it into reality, knowing that you built it from the ground up? That's a hard feeling to replicate.



When forced to blog in the future, I'm sure I'll turn to more technical aspects of the course. It definitely wouldn't hurt to write a blog post on just using the keyword "this" and the pains of the damn thing. Anyway out there who knows what it is, you know what I'm talking about. But tonight I needed the emotional vent. It's been a hard week, my grandfather's surgery, my wife's struggles with depression, my own disappointments. I needed to admit out loud (sort of) that this is hard, so much harder in different  ways than what I expect. But I've also been having a great time. And once in a while, you just need that reminder. That it's worth it. That you can't quit. That it may be rough right now, but it's going to be better.



I think I'll leave it on that note. I can feel something trying to pound its way out of the back of my skull, and my wife has fallen asleep on the couch, waiting on me. To anyone who read, thank you. And if you're in this program now, or you're thinking about it, keep this in mind! Hopefully my later posts will talk of more breakthroughs and satisfaction. But for now, I'll just have to be content with the idea that it's coming. And it will be all the more worth it when I get there for these struggles now.

Tuesday, June 7, 2016

Week 1 Day 1

First impressions are funny things. They're often wrong, sometimes wildly so, and you can look back on them and realize how weird it was that that was what you thought the first time you experienced that thing. I can think of many friends that I hated when I first met them, and many enemies who I thought were the greatest people in world. I've read a book the first time and come back to it a few months later only to realize it was complete tripe. I've left the theater talking about how awful a movie is only to go out and buy the box set deluxe edition when it comes out because I suddenly desperately need it in my life. First impressions aren't the best rules to follow when forming your opinion about something. But we have them for a reason.

Bad first impressions can turn you off of something for the rest of your life. But good ones can keep you going in something you might have otherwise hated. How something begins can be even more important than how they end, because you may not have reached that point if not for how it all started.

And it looks like my first impressions of Hack Reactor are going to be the type that keep me going. Not that everything was good, or that the first day was the most orgasmic of my life. It's only the feeling I'm left with at the end of the day. I'm exhausted. I'm a little frustrated. I'm worried about how the other days are going to be and if I've made the right decision. But I also have the overwhelming feeling that I can do this.

It's the balance of how the staff talk to us I think. We didn't walk in here to tales of how we can all do this, no problem, how we've got all the right stuff in us and we're going to get through this unscathed. But they didn't hound us with fearful images of frustrated suffering at the hands of a drill sergeant. There was a balance, a balance of "You got in! Everyone here, they've all gotten in, and that's not easy. You're all incredibly intelligent people and you did a lot to get here" and "Now I'm going to ask even more from you."

I felt like there was really a certain zone they were trying to get you in to, and it's a very difficult zone to sit in. They want you to be challenged, to stretch to the very edges of your ability, but to not have your goal out of reach.

Have you ever played those games where you have to hold a bar at a certain line? Don't push too hard or you'll go past it, but don't go too slow or you'll never make it? It's like that. There's this line you have to sit at, this line you have to straddle. And the first few days, it's going to be learning to straddle that line.

And not everyone's line will be at the same place. Some people's line will be drawn on skyscrapers, while others could be drawn on a corn stalk. But one thing that seemed to be sure - it wouldn't take long until all our lines would be even on the horizon.

At least that's the feeling anyway.

You can't really take the whole experience from a single day. I honestly can't tell if this is what the rest of the days are going to be like, or if today (now yesterday at time of writing) was just the prelims and everything else is going to be a tidal wave of alien ideas. There were goods and bads in this first day, and my opinion may change as we go through, but this is where it sits now:

The bads - Let's start here. There isn't a whole lot I can put into words here, at least not anything I could say that wouldn't be blatantly obvious. To start with, we're a big cohort. Over 40 students apparently. We were originally going to be cut into two simultaneous cohorts, but for whatever reason, that idea went out the window just a few days before the class began. I do feel a bit of being lost in the crowd, and being a naturally loud person, it makes me want to get my voice heard, which could definitely come off as obnoxious. And I can imagine what it would be like for someone who was super shy. If I was a nervous person (which, hey, at heart, I kind of am), I would feel like I was standing in a dark corner in a room full of Leos, waiting for my chance to talk to the guest of honor - whenever they got the chance to get through everyone else. So that isn't super fun.

There's also a bit of confusion on what we're supposed to be doing. I know it's probably hard for the staff running this, many of whom have already gone through the class and are therefor used to the curriculum, to really grasp that a lot of this is foreign to us, but I wish they could communicate better. We've been given a google calendar that has all of the tasks for the day, and when they start and what we're doing and who we're doing it with. Which is definitely great, only they didn't do a great job of explaining it. The intro lecture, the one that was supposed to be teaching us all about Hack Reactor, was long and tedious, although the lecturer did do her best to try and keep us engaged. I only wish the explanation of the calendar hadn't been hidden in the midst of that, and near the end too, when we were already tired of listening to her talk about somewhat preachy ideals about self-worth and responsibility. But I think even with that we would have gotten it better if she had gone over it briefly again just before we dispersed. At least on the first day, a little more hand holding in that area would have been nice. I appreciate the do-it-yourself attitude, but it doesn't work too well when we don't know what you want us to be doing.

But on to the goods. There was a lot of positive bits in this first day. I'll definitely give them that there as enough going on, enough new ideas being passed around, to keep us interested and motivated. They made sure there was alwasy something to do and did a good job of making us feel like we were really in a school setting rather than just watching a school setting at home. 

I was also really nervous about the long day, and how exactly we'd have to cope with it. I did 11 hour work days for several months one summer not too long ago, so I knew I could do it. But I had had 3 days off a week in those stints. To do 11 hours 6 out of 7 days, that did seem like a tall order. But I was prepared for it. I had visions of myself chugging through, downing 5 hour energy shots and working myself ragged. I'd done similar work before, I was prepared to do my best this time.

But it wasn't quite what I expected. Yes, it is a very rigorous schedule, and there's not too much faffing about to be had. But it's not the stress riddled mad dash I expected it to be. It's more a marathon. Meal breaks are a generous hour and set at proper intervals, and it's not a whole long line of lectures. They make sure to break it up and ensure you're interested.

We started with the lecture about Hack Reactor, and orientation of sorts, that lasted about an hour and a half or so. But after that, when I was expecting to be thrown into another live lecture with the stress of paying strict attention to every second of the remainder of the day, I was instead given two recorded lecture videos and sent on my merry way.

Well that was different. They had given us a few extra minutes to watch the videos, so I could start them immediately and have a little time after or start them after a short break. And I was starting them on my own terms. Which felt good. It didn't feel like I was being dragged about by my nostril hairs, but more like I was doing this for myself. And honestly, despite the fact that I was doing the same kind of work I would be doing in the live lecture I had imagined, the stress just melted off of me.

After the videos, we hooked up with a peer to pair program for a short time - another adventure that I had luckily had some experience with before, with Hack Reactor Remote Prep. The exercise went pretty smoothly, and it was kept to just a short sprint, ensuring that we got a taste but didn't get too frustrated. And then suddenly it was lunch time and I was free to listen to my audiobook for a bit while I ate some lovely orange chicken. By the time we came back to work, I as feeling refreshed and really eager to keep going.

The next part was a 45 minute live lecture about life at Hack Reactor and what we could expect from the program. Then we went over everyone's questions, talked for a bit about how we were feeling, and then it was right back into pair programming.

My partner and I (a lovely young woman who had also done the Remote Prep course, though in another cohort) worked pretty well together, boosted by the confidence the previous talks had given us, and worked for the next 3 hours with little difficulty. It was a rather empowering moment, and the time flew by. I was actually mad when I checked the clock and realized we had hardly any time left, which I suppose is a testament to the system.

The day ended with a Townhall, a lecture on effective pairing (which was definitely funnier than it should have been since I watched it at 1.5x speed), and a Q&A, but at time of writing, I'm on lunch break from W1D2 and the details are getting fuzzy and I'm way too hungry to think about them. For now, I'll sign off. Perhaps my post at the end of today will be a little shorter and give me a chance to touch on Townhalls a bit more.

Monday, June 6, 2016

Before Hack Reactor

So this is mostly for my own reference, a journal to look back at later and laugh at how silly/naive/eager/crazy I was going through Hack Reactor. But maybe it might help some other people out there as well! Perhaps you're getting ready to join your own cohort, or maybe you're only thinking about it. Maybe yours is already half way over and you're just wondering how other people's experiences compare to your own.

Well, in any case, it would be good to know what kind of background I'm coming from. I am not a programmer, at least not one in any way formally trained. I started out when I was 14, designing skins for play-by-post, forum based, roleplaying sites. I was strictly asthetics, knowing the ins and outs of css so well I could pull the (almost) perfect color hex code strictly from memory. But I was an avid Javascript hater, for no other reason than I didn't understand it. I was out there doing things with css that should be done in Jquery. Believe me, it was no small task to create dynamic websites, beautifully flowing pieces of artwork, working with something that was never intended to be used the way I used it.

So needless to say, I felt comfortable in my niche and had no intention of leaving it.

It wasn't until many years later that I suddenly realized how silly and childish I was being. I had skirted anything on Stack Overflow that had a Javascript tag on it like it had the freaking plague, and had gotten frustrated and annoyed with the peers around me who tried to help me out with tidbits of Javascript knowledge. And it was beyond stupid of me. I was ignoring a whole wide world of other wonderful languages, libraries, and APIs that were sitting at my fingertips, ready to be used, and only left neglected because I had some weird kind of coding racism.

So needless to say, I was a little lost when it came to Javascript. Granted, I had taken a class on C++ when I was in high school (and really enjoyed it, might I add), so I had some knowledge of how programming languages worked and the logic behind them. But stepping into the world of Javascript was like a man from the 1800's stepping into the world of sports cars and airplanes for the first time. I was lost and scared and frankly annoyed at all the loud noises around me.

My journey started with codeacedemy.com. I had flipped around the internet for a while, trying to find the best way to learn. I had gotten so many different suggestions from so many different people, it was hard for me to look at anything and say, "This is the right path for me." Luckily, I had my beautiful wife to help me out. When she saw my sudden dedication to learning new things (something that was only occasionally strong in me), she jumped right on board with me, doing research along side and trying to find the answer to all my problems.

Now I trust this woman implicitly. When she told me Hack Reactor was the best route out there, I didn't question. She is the research goddess, able to google like it's an olympic sport and she's a 6 time gold medalist. So suddenly I was prepared to throw my all into this new career, without any other knowledge besides it was going to be insanely hard and (if I made it through it) I could make crazy good money. Not a great start into this program, but that was my attitude at the start.

So I interviewed. And I failed. Of course. I had done a good 4 months of research on Code Academy before the interview and, despite how unsure I felt about some things, I'd figured there was no way I, who had been building websites for 8 years by this point, and who had never had any trouble passing tests in school, could possibly fail a simple interview into a school.

I learned very quick that this place wasn't what I thought it was.

When I got my email telling me I hadn't passed, my whole world kind of melted around me. That was it for that, apparently. It was time to continue my career in the retail world and keep playing around with skins on my off days for free. Ah well. I tried. But there was something in the email that kept me from leaving.

"Though you did not pass the technical interview, your interviewer found you to be a particularly promising candidate."

Well what the hell was that supposed to mean? I hadn't passed but you thought I could if I tried harder? Was this just some kind of money-grubbing scheme to force me to pay for more classes from you before you let me into the real class? Or were you genuinely interested in seeing me succeed? I stared at that email for a good 10 minutes, trying to figure out if it was worth it or not. But looking at that line, all I could think was "Challenge Accepted."

So I joined Hack Reactor Remote Prep #21. I did not feel great about it. I didn't even feel good about it. I was sure the class was going to be cut into two types of people - the ones who knew absolutely nothing and were terribly frustrated about it, and the ones that knew absolutely nothing and were blithely ignorant of it. And that just wasn't the setting I wanted to be in. I wanted to be somewhere where everyone knew a good bit already, and I knew just a little bit more than everyone else, so I would never look like a fool. This surely wasn't going to be that kind of setting. I was looking at it as something I had to do, not something I wanted to do. Honestly, how can I possibly have fun? 

I have never been so wrong about something, or so happy to have been such. I would say that, to date, taking the Remote Prep class was the best decision I had ever made. Even joining Hack Reactor wouldn't have been possible if I hadn't taken this step. I know how I am. I would have gotten discouraged easily when I didn't immediately understand what was going on, and I would have quit, simply accepting that this wasn't for me. 

I'm going to have to do a post all about my experience with Remote Prep. I could talk for days about everything there, I there's no need for me to go on and on here. But suffice to say, before HRRP, I had very little experience in the programming world, and before HRRB, I was just comfortable enough to go through the course, but certainly not enough to fly through it. I can tell right now, this is going to be one hell of a journey. And as of right now, I'm super psyched to take it.

~Ryo