Wednesday, February 12, 2014

Agility: Chapter 2

So I've decided to skip over chapter 1 in "Agile Web Development", mainly because there are enough explanations and blog entries out there about how to get the Ruby and Rails code installed on my machine, and to write one myself just doesn't sound very engaging right now. So on to chapter 2! Instant Gratification

Creating a New Application

When I first jumped in to learning Rails, my big brother would regularly tell me, "Remember: convention over configuration", and I would nod along like the good non-understanding liberal arts student I was so as to hide my ignorance, enabling the conversation to move forward in hopes that something would eventually be said that made sense to my non-technical brain.

My experience in coming into the web development industry was that there is generally a background of some kind of computer education among web developers. For me, there was zero, which means that when my brother talked about configuration, I could give a definition of the word, but I had no understanding of its relevance when it came to writing program code.

And in all honesty, I still don't really know what it means beyond this: configuration is what allows all your bits and pieces of code to play nicely together. It is code that get your other code to do its code-ly responsibilities...I think.

Putting this into context, the first section of chapter 2 in "Agile Web Development" states "Rails..does a lot of magic behind the curtain to get our applications to work with a minimum of explicit configuration." I never went to Hogwarts. I didn't get wand and a hat never determined my the greatness in my blood, so when I hear that rails does a lot of magic, I think I'm best just saying thank-you and moving forward. This "magic" that the book speaks of is essentially configuration code that makes everything play nicely together, relieving the coder of the work to make it all work.

When you are ready to make a new application with Rails, you simply type rails new and "magically" Rails generates a dizzyingly hefty sum of files right before your eyes. Fortunately for newcomers, the files of immediate concern are rather slim and give a good foundational template off of which to build.

Controllers, controllers, but what to control?

When I first started toying with Rails, I had absolutely no idea what purpose the controller played or how it interacted with the rest of the application. Once again, I still don't fully understand the controller, but I know that it is a very, very powerful component, and it can do magical things with your application if you've got the mad Ruby ninja skills. I don't have said ninja skills (or even dojo janitor skills), but I know that there is much value in understanding this part of the application. When I fully harness the power of the controller, I will have..erm...control of my program.

I conclude my entry with this; views display the information, controllers direct the information, models shape, retrieve, and store the information. When a user sends a form in the generated view, the controller snags the information being sent and assigns it to the appropriate model to be persisted in the database. When you think about it, it is a pretty simple concept. Now to figure out all this code that is getting in my way of producing what I want.

Key Terms from Chapter 2

Command-line Tool
A tool used at the command line the the form of a single word. Usually other words follow this word that issue further commands as to what you want the command line tool to do. Often typing --help after the command-line tool word will present the user with a list of things needed to be known to get started.
Directory Structure
The way in which your program code is organized. Because Rails follows convention over configuration, each Rails project you create, or work on, is going to have extremely similar organization.
\
MVC
Stands for Model-View-Controller. This is a system architecture that divides code up into the function it plays within the rest of the application. Models are responsible for storing and retrieving data from the database. Controllers can, in a way, be considered responsible for control flow of the application. They send data from the models to the views, and when a browser submits a form, the controller directs the pertinent information to the models for processing into the database.

No comments:

Post a Comment