Pragmatic Rails Studio Day 2

February 18th, 2006

You can read about day 1 if you haven’t already and afterwards be sure to read day 3.

Day 2 impressed upon me quickly that despite understanding all the concepts, I have a ways to go in purifying my code. I never realized it, but I often put business logic in the controllers and occasionally even the views (*gasp*).

Unit Testing

One of the first topics covered was unit testing. I was really interested in this as I have never did any kind of testing. Unit testing is not only simple, but it is fun and assuring. The biggest thing it means to me is that if I don’t touch my code for a month while we are waiting on a client, I can simply run a test and be assured that everything still works. I don’t have to worry about popping an error in front of a client during a demo. It also means I can make changes to any code and know right away if I screwed something up. I don’t have to wait for a phone call. Dave mentioned that code difficult to test is code difficult to use. Testing your code helps you write not only more solid code, but easier to use.

When Trouble Strikes

Another interesting topic was what to do when trouble strikes. Mike and Dave provided several scenarios of common problems and solutions. They also listed several techniques for troubleshooting such as tailing your development log (tail -f log/development.log), removing session files, using script/console, writing tests and setting breakpoints. They also provided a couple examples of rare but difficult problems that can occur.

Components

I watched a video the other day on components that are stored in the components directory. Frankly, it looked confusing and kind of pointless. Thanksfully, Mike and Dave said this type of component is falling out of favor. Instead, components are just calling a controller and action from somewhere in the application other than that controller and action. I have used this type of component before and thought it was handy. I used it for latest news and upcoming events. I made an action in the news controller called latest. Then, in order to call this component on the home page or in a sidebar I simply write render_component(:controller => ‘news’, :action => ‘latest’).

AJAX

Ah, the never ending buzzword of the last year. I’ve been using prototype and scriptaculous for at least five months so AJAX is nothing new. What was new and refreshing is how easy it is to do AJAX with Rails. I have already purchased Chad Fowler’s Rails Recipe book, so I was prepared for the coolness of Rails and AJAX. My only fear of the ease is that it will be abused and that people will use it simply to use it. I’m afraid that they won’t think about why they are using it because it’s simple.

Web Forms

Web forms are extremely simple in Rails thanks to all the helpers. We received a small intro and because of my previous familiarity with this section, I won’t go into it much. The day ended with a small talk about how to integrate legacy systems with Rails. Again, this didn’t have much to do with me, but it was interesting to learn about and I know that some of the other programmers were eating this part up. Day 2 was good, but covered alot of things that I already had experience with.

You can read about day 1 if you haven’t already and or move on to day 3.

One Response to “Pragmatic Rails Studio Day 2”

  1. against all odds quotes…

    subroutine hewer trek rustler,Agatha online …

Leave a Reply

About This Site

Addicted to New is the personal website of John Nunemaker (Noo-neh-maker), a Web Developer enamored of Ruby on Rails and a wide-eyed fan of all things new and cool.