Monday, May 22, 2017

Hackbright Week 7: The Power of "This"



When I think about my current state--the state of being at Hackbright, where my main job is to learn--I'm sometimes caught off guard at how much we are all living in the now, the present, this moment. If we weren't, we wouldn't have quit our jobs and previous lives, given up a good part of our social lives, and forked over a fortune of money with the chance of having these sacrifices drag on for another good couple of months afterwards while we're job hunting if it weren't for "this".

Today, in modern meme times, when you hear someone say something that resonates exactly with how you feel, it's not uncommon to say "This" while expressing some kind of way of pointing to the message, like via a carrot or physically pointing with a finger. More accurately, according to Know Your Meme:

^This is a single-word demonstrative pronoun used on message boards and social networking sites to show agreement with quoted or reblogged posts. Besides its usage as a single-word text post or tag, the term can also be found in image macros and reaction GIFs in which subjects are shown pointing upwards.

In the world of programming--Javascript to be exact--the concept of "this" is also something to be revered with high regard if you want to keep up with your code. I'll admit, I'm [only] 26 but honestly I refused to acknowledge the importance of memes until I realized they were going to stick around for a while so dammit I needed to at least keep up with the times to retain my youth. Anyway, same goes with AJAX requests. The first time we were introduced to them, I was like huh, these are cool but I think I'll stick with my handy, trusty form submissions. 

Of course "this" way of thinking is most likely the reason why until I struggled (and am currently still struggling with) converting a lot of my code into seamless AJAX post requests, now that I realize how critical they are to making my user flow work. 

Our TA said that as an inside joke, the ed staff would assign "this" to a variable named "that"

What happens in AJAX requests is that you are basically putting a stop/hitting a pause on a standard behavior of an element (e.g., the submit button of a form), intercepting the request to customize what you want to send to your server, and making your program report back to you on what happened via a success function. So you are getting stuff done in the backend and changing things on a web page dynamically without needing to make it refresh a million times.

Cool, huh? It sure is, but only after you've been exposed to "this". So when you click on a button to put a pause on its action, how does your app know which button you are stopping? "This" was the easiest answer that one of our TAs told me to use, and boy was she right! If you have a class of buttons that would behave the same way when clicked, the one you click on now becomes "this", and you can perform various actions on "this"and its parent(s), sibling(s), innerText, innerHTML, etc.

What magic, what fun, what happy discoveries! This is what I'm doing now and this is what I will be doing for a living. This is what makes learning about code so great. 

This.


No comments:

Post a Comment