Thursday, April 14, 2011

Agile Web Development with Rails

Ahh, it feels good to have a new coding book! Online tutorials and help from srs Rails guys is a fantastic resource, but a good book is absolutely invaluable.

I picked up a copy of Agile Web Development with Rails this week. I even sprang for a hard copy, despite my philosophy against owning physical media. Seriously, cavemen had books. Look it up. Anyway! I finally got a chance to sit down with it this evening. (Saying "finally" here is funny, since I just got it yesterday, but couldn't do anything with it since the Indy RB meetup was last night)

STILL, "finally" feels appropriate, considering I spent all day at work foaming at the mouth to get home and start coding. So far I really like the book. Like Beginning Ruby, it's written in an easy to follow, engaging manner with practical examples. Is there any other way to write a coding book? Probably not if you want people to read it. So far a lot of what I've seen in the book is refresher material for me, since I've spent the last couple of weeks doing Rails work by following online tutorials and working on Dungeon Roller.

Still, I've already learned some helpful things. Such as having two terminal windows open: one to run the Rails server of my project, and one to perform tasks. I had no idea! It simply did NOT occur to me that I could have two windows open. Another helpful tidbit came with generating a controller. If you write the code as such:

rails generate controller Say hello goodbye

Rails creates a controller named Say, with two empty methods inside of it: hello and goodbye. This definitely saves time later, because up until now I'd been writing methods by hand. Finally (and this is getting into code theory, but we're talking kiddie pool stuff here) I learned the idea that the controller holds the data and the view displays it. Pretty basic, but essentially even though you CAN write code directly into the view, it's a better idea to have the controller handle it. This idea is similar to separating raw HTML from styling.

On a side note, I've decided to rename Dungeon Roller to Manticore, both as a nod to Dwight from the Office and in homage to my favorite mythological creature.

3 comments:

  1. Excellent. I'm glad you're like AWD.

    They code theory you're talking about (MVC - model, view, controller) is something I've started thinking about every time I write code. Matt Gordon told me that after learning the syntax, one of the hardest things about coding is deciding where the code should go.

    MVC tries to answer that question, but even with MVC as an approach, there is grey area. You start to have helpers and shared code which play across different parts of MVC and it starts to get trickier.

    ReplyDelete
  2. Terminal +1
    Rails generators +1

    I think you just leveled up!

    ReplyDelete
  3. @Brennan Thinking about the MVC every time you write code is a good habit. It took me a while to really "get" why stylings and html should be separated and I see this as a logical extension of that idea. This book is awesome so far and I'm really glad you recommended it.

    @Eli I definitely feel like I've been leveling up since I got this book! It's answered a lot of questions I had about how putting things together works. +3 to Code Spear!

    ReplyDelete