W3D3: a conductor, or an engineer?
There is a point at which abstraction and encapsulation, while they make accomplishing complex tasks much faster and simpler, make learning and intuition much more challenging.Â
Today we did our first in-class rails project, exploring a fraction of the magnificent encapsulation of ActiveRecord, an impressive ruby gem that allows one to build complex data tables and execute complex SQL queries with a startlingly simple (if occasionally mildly counter-intuitive) ruby API. We began with a few short exercises building associations and validations between various data table classes, getting comfortable with syntax that is essentially communicating between three frameworks (ruby, sql and rails). after our warmup, we developed a working url-shortener, which could keep track of individual users, urls they had input to be shortened, the random strings that would represent those urls and data on the number of times these links were visited. My partner and I didn’t have time to test our cli’s use of the launchy gem to make sure our code would actually launch websites when prompted, but it certainly stored user, url and visitor data in tables with the correct relationships!
It was jarring, so soon after learning SQL (mere hours, really) to be pulled back a level of abstraction and need to call SQL commands through ActiveRecord. Since I love puns, I’ll describe it thus: I felt like a fledgling engineer who had just gotten excited about the design of an efficient new steam engine, only to be stuck driving a train powered by that engine and asked to safely conduct the train along the rails and into each station. “What do these knobs and dials do? Put me back at the drawing board, I’m not a conductor yet! I’m hardly even an engineer!”
I felt a little overwhelmed until moments ago, when I experienced what I have decided to refer to as a quadratic epiphany after restarting my laptop. using trusty old “cmd + space”, I opened spotlight to start launching applications and was momentarily frustrated when the search algorithm didn’t yield immediate results.  I looked below to see an output of “indexing...” and for the first time, I truly understood what that meant. Why my drive needed to be indexed after rebooting, what a dramatic difference indexing makes for optimizing searches... it was one of those moments when unexplained past experiences all line up and get simultaneously illuminated.  Aglow in my newfound clarity, I didn’t mind waiting a few moments for the indexing to finish in order to dramatically reduce my overall time complexity...
...and then considered the implications of my moment of truth further: using rails to develop code is much like indexing storage. though it requires a little more work in the beginning, that work is dwarfed by the amount of time and computations these approaches save as n approaches asymptotic infinity. I know my life span isn’t infinite... but all the more reason to invest time and energy now, and seek the greatest returns!
with that, I’m off to get some rest. You reap what you sow.