< prev 3 Dec 2014 to 3 Dec 2014 next >

Posts from 3 December 2014


    Today's partner: Mark S.

    Today was all about Controllers. Well, and ActiveRecord relations and SQL queries… first things first.

    The assessment went really well, I believe for most people, but especially for me. I did the practice assessments two (and a half) times, and when I came in this morning asked my neighbors what they had done to practice. One had a really good suggestion—look for foreign keys early on, in the schema.rb file, and then implement the belongs_to relations based on those keys. With this hint, a bit of practice, and a much greater understanding of SQL, I didn't really have any issues with this assessment.

    The readings last night were a different story, and I was really worried about how the day would play out. I knew coming in that today was going to be about the C of the MVC paradigm - we've covered models, we'll get to views tomorrow, and we were doing controllers today. But none of the readings we had to do made it clear what, exactly, controllers would consist of. I sort of struggled through, and collapsed into bed.

    Well, this morning, it was much more clear. During the lecture, Jonathan and Constance showed us a lot of the same stuff we saw in the readings, but watching it live, it became clear how it was going to fit together. REST combined HTTP verbs with URIs to produce a variety of different responses… which are handled by the routes handles in routes.rb and the controllers generated by rails.

    There's not a lot to say about the controllers themselves—you define them in a predictable way, they have actions defined in an easily readable way, and you write those actions in pretty predictable ways.

    Ultimately, because rails is actually pretty sane, learning more about controllers teachers you a lot about generating, models, and I presume views… in addition to me focus on learning snippets, shortcuts, and so forth, it feels like we're really picking up speed. Or at least I am. But looking forward at the readings, there are certainly a lot, and it's clear that having a repeat of today—hard work, but valuable—will require sticking to the readings and making sure I'm ready for the next day.

  • Week 3 Day 5 - define_method(:meta_program)

    Today: solo

    As others have remarked, because of the holidays, the weeks and days are just pointers to lesson plans, and not actual days and weeks. I actually got to the end of the day yesterday and asked someone "what day is it?" honestly hoping that they'd say Wednesday. It felt like a Wednesday.

    It wasn't Wednesday.

    (week 4, day 2)

    Today was all about meta-programming, centered around the ActiveRecord Lite pet project. Real ActiveRecord does a lot of the work of writing repetitive code for you, and our toy AR did a lot of the same things, albeit not as gracefully. Meta-programming itself revolves mostly around defining methods at runtime that build out in predictable ways, so you can do all that cool stuff for free.

    It's actually quite nifty, if only you are able to keep track of who will be calling each of the methods you write and where. In essence, Ruby offers faculties that permit you to give methods to a class or an instance (or an instance of a class…); variables can be local, or belong to the instance, class, or class instance… I'm still not totally solid on all the distinctions. My coding style today was essentially "keep changing whether you say self or self.class or self.name or nothing at all until the damn thing passes."

    Aside: A potential project for a later date would be to make a simple file full of classes, instances, and modules, and see how different things behave and what they think they are. To wit: I could make a Module that extends a Class, and see what that module's methods say they are, and then include the same module in the same class and see what the methods do when they're called by instances of the class…

    A huge part of reading and understanding code centers around being able to simulate system state in your head, or at least to scan idioms and interpret them subconsciously. Like reading English, you can only leave so many pieces as null references, hoping to pick up their meaning through context, before the main idea of the block is completely lost.

    Anyway, so I felt like I was lagging all morning, and yet again, once lunch had passed I picked up a lot of steam. (There's gotta be a better way to get through the morning doldrums!) I managed to complete the exercises with five minutes to spare, and it felt really good.

    I was much more patient and thoughtful today than during Checkers. At lunch I thought this post would be starting with a discussion of my demons, but being aware of them and having to face them a solid day at at time seems to be working.

< prev 3 Dec 2014 to 3 Dec 2014 next >