
I am diligently working through the iterative-based example in "Agile Development with Rails" by Dave Thomas and David Heinemeier Hansson.
Thus far, I like the book's style and approach. I'm only on page 131, and this is the 2nd edition (covering Rails 1.2), but I really like it so far and would recommend it.
I wish they had chosen a different application from the "classic online store with order cart" example, but I guess its the new Hello World!
Vis a Vis Rails,
I love generating model objects and controllers using the scripts.
Also the URL dispatch by convention is pure joy. At first glance, this seems to encourage and result in RESTful-looking URLs.
I am probably most impressed with the whole framework around DB migrations. DB design and ORM mapping is such a fundamental part of the classic MVC app, I love that this process is integrated into the framework. It somehow keeps you thinking in Ruby and I avoid the sinking "Now its time to to write SQL" feeling I get when messing with the object/data model.
What I didn't like at first:
At first, I wasn't sold on Embedded Ruby in the views.
<% %>
<%= %>
I was a fan in Java MVC of keeping JSPs pure, utilizing taglibs wherever possible and using the standard JSTL religiously. "Is there no analogue for Tags?"
Then I thought about it in Rails context.
1) Ruby is a great language, and its already interpreted. In a sense, it isn't nearly as hacky as embedding Java in JSPs. And part of the point of Rails is to let you use Ruby BECAUSE of its expressive power.
2) The view feels like a part of the controller instance. Probably in ways I don't understand yet, the view is much closer to the Controller than in J2EE frameworks. It appears you actually call controller functions in the view and you access instance variables like you are still in it.
3) Helpers seem to take the place of tags... and they seem to be controller specific. Easy to write, if they are the answer for keeping it DRY without clunky formalities... I am buying in to that one.
It occurs to me now that MAYBE... JSPs, Taglibs, JSTL, EL Expressions were not necessary parts of the J2EE framework... or at least they wouldn't have been necessary if Java had the powers and flexibility of Ruby.
What I still don't like:
X) I just finished the AJAX chapter, I am not convinced (yet) that .rjs templates are a good thing. I guess I don't understand them enough, but it seems as though there is unnecessary complexity in hiding prototype, scriptaculous, and other DOM functions behind Ruby libraries. I definitely am willing to suspend judgement on it for now.
Y) I did appreciate the ease in which you can make the use Ruby to define and make the XHR call from the view (using form_remote_tag), but I am still a bit gunshy of server-side code that writes JS. Its seems to me that in most applications developers will want more control of the JS and DOM to use existing or 3rd-party libraries, etc.
Z) I don't see render(:partial => ...) as an elegant solution. On the other hand, maybe they are just keeping it simple (as opposed to creating some heavyweight formality like Tiles, etc.)
Overall, a successful first foray on Rails. I think I am going to press on with the example, fighting the urge to hack out the next Web 3.0 sensation with my new Rails skills.
PS. I am using RubyMine IDE from JetBrains on Mac OS X and loving it. I am currently an IntelliJ user, so perhaps this has colored my perspective but it has been error free and easy to use so far.
No comments:
Post a Comment