Currently viewing the category: "Rails"

The last part is easy. Now what is architecture as related to software development, that’s a much harder problem (42 is still a good answer of course). I think I just read the best explanation of what it is.

Roy Fielding(inventor of REST) gave a talk at RailsConf Europe entitled “The Rest of REST“. The last slide really sums it best:

use principled design:

  • identify desired architectural properties
  • constrain behavior to induce properties
  • compensate for the inevitable design trade-offs

I think this is the best way to really understand why constraints are liberating. When designing, you choose the properties important to your application (whether it be efficiency, scalability, maintainability or any other -ilities). The architecture will codify a set of constraints that should lead to your application having these properties. These constraints free you from having to constantly think about any of the properties, as long as you respect the architectural guidelines.

An example from the slides: Constrain interactions to be stateless. This simplifies the server, improves scalability and reliability. However, it degrades efficency. Checkout the slides as Roy gives very detailed info on the advantages and tradeoffs of using a REST architecture. Seriously, these slides are gold. I will read them again and again over the next few weeks.

Popularity: 11% [?]

 

The Rails Edge: Quotes and Notes is a very interesting collection of quotes from the rails edge conference. Two in particular caught my attention:

“Metaprogramming + DSLs is the Ruby equivalent of Design Patterns in the Java world”
— Chad Fowler. Fowler’s point here was more about the buzz and hype, just like there was a time in the early 2000s when every Java programmer wanted Design Patterns whether or not they were needed, Fowler sees a similar rush to add DSLs to Ruby programs.

“If programmers, on average, were able to write parsers and compilers, Ruby on Rails would not have taken off”
— Stuart Halloway

This is something I’ve noticed a lot recently: every plugin that gets released is a DSL! or it uses a cool metaprogramming trick! That’s nice, but was it really needed? And can we really talk about a ‘language’ when your plugin adds two simple commands to a controller?

I guess it’s a rite passage when learning ruby to write something using metaprogramming. The problem is when you start using it for everything, just like when you add patterns after patterns to your code, just because.

Again, this is a case of using the right tool for the right job. Metaprogramming is a power tool that is useful some time.

Here are other quotes that I like, as they echo the discussion I had with Fred Brunel at the last book club about process:

“The right process is always ‘not quite enough process’”
— Stuart Halloway

“Do the dumbest, simplest thing that almost works”
— Stuart Halloway, on process

“The traditional view, with sixteen pounds of documentation, introduces a single point of failure in the process, understanding the problem domain”
— Dave Thomas

“Getting a specification involves bullying the customer”
— Dave Thomas

Popularity: 14% [?]

 

Last night was the second edition of Montreal On Rails, with 50% more stuff! (3 presentations instead of 2) My thoughts on the presentation:

First up was Chris Scott, who presented the extjs Javascript framework. Notes to future presenters: please make sure you take 15 seconds to explain what the framework is and why I should care at the start. Don’t wait 5 minutes where you’re setting up your example to finally drop a ‘btw, extjs is a widget framework’. The presentation started slowly with basic stuff and moved on to bigger and better things at the end. I was really impressed by the layout management possibilities that extjs offers.

There was a lively discussion after the presentation comparing extjs to Protoype. Someone pointed out the obvious that prototype isn’t a widget library, but extjs seems to also cover a lot of what the prototype/scriptaculous combo can do.

I’m not a fan of javascript widgets library. I just don’t think it’s a good idea to want to emulate all desktop application functionalities in a web application. Working with the constraints of the web browser forces you to look for simpler alternatives.

Second presentation was by Chris Lamothe who did a demo on how to add user authentication to your rails application using acts_as_authenticated. It was geared toward newbies. He also briefly mentioned a plugin I didn’t know about, role_requirement, that adds basic role based security to acts_as_authenticated.

“Client-side debugging in Firefox” was the title of the last presentation, by Terje Tjervaag. Actually, he quickly presented a couple of Firefox plugin like Web Developer Toolbar, Firebug and YSlow. If you don’t know about these plugins, download them now! There’s no way I’m going back to using Firefox without Firebug (except for the increased slowness and memory usage). It allows you to poke at and modify anything in your web page, live. Terje seems really knowledgeable about testing the view/javascript/browser issues of an application and I hope he can do a more advanced presentation someday explaining how he does it. Right now, my automated testing stops at the models and controllers.

Suggestions for next presenters: although it’s nice to show live how to do things, you don’t have to type everything in front of the audience, especially when we can see the complete examples commented just below what you’re typing. It’s OK to copy paste. You can also have a basic rails application already setup with what you need. This would help speed up presentations next time.

I hope I don’t sound too critical of the speakers. They did a really good job and I realize that speaking in front of people is not easy. I wouldn’t have done better myself.

The best part of the night was after the meeting, as we went to McClean’s for burger and beer. I had an awesome discussion with Marc-André Cournoyer (read his report), Carl Mercier and Francois Beausoleil (who will be doing a presentation on piston next time). We exchanged war stories and talked about every subject concerning rails from deployment to testing to plugins we use. I hope we can do the same next time!

Note: The next meeting will apparently be at the StandoutJobs office. I bet this is just a ploy by Fred to make sure every rails programmers in Montreal wants to work for them. ;)

Popularity: 23% [?]

 

One very useful feature of Texmate that few people seem to know about is Textmate Footnotes. It’s a Rails plugin that adds this menu at bottom of your pages:

Textmate Footnotes Menu

When you are testing your app, you have links that takes you directly to the contoller, view, layout, stylesheets. You can also see the session, params and log for the current page. If you get an exception in your action, each line of the stack trace is turned into a link, taking you right to the file at the correct line where the exception occurred. If you haven’t tried it yet, what are you waiting for?!

Popularity: 8% [?]

 

I just changed my iMac G5 to a MacBook. There are lot of instructions on installing Ruby and Rails on a Mac on the net, some of them not quite up to date. Here is what I find to be the easiest way to do it.

  • Pop your Mac OS X install disc 1 and install the xcode tools. (this installs an old version of ruby)
  • Download and install MacPorts
  • open terminal:
    sudo nano /etc/profile

    Prepend /opt/local/bin: to PATH, so it reads:

    PATH="/opt/local/bin:/bin:/sbin:/usr/bin:/usr/sbin"

    This is to make sure the new version we are about to install will get used instead of the old one.

  • Make sure MacPorts is up to date:
    sudo port selfupdate
  • Install ruby and rubygems:
    sudo port install ruby
    sudo port install rb-rubygems
    ruby -v

    This last command should give 1.8.6. If you see 1.8.2, this means it is still using the version installed from the OS X cd. Make you correctly updated your PATH.

  • Install Rails:
    sudo gem install rails -y

You might also want to install subversion right now using ports:

sudo port install subversion

(Note: at the time of writing, Rails is at version 1.2.3 and Ruby at 1.8.6. )

Popularity: 6% [?]

 

Tuesday night saw the birth of the Montreal On Rails user group in a small room on the Mcgill campus. It was a lot of fun.

The first presentation was by Marc-André Cournoyer, Standout Jobs Ruby Guru, entitled “How to make your tests faster”.
Marc-André started with a very funny introduction. I don’t know how to describe his intro. He should turn it in a video for all to see. First part was a demonstration of caching results from external apis (he used twitter as an example) to a file to make tests go really fast on your development machine. You then add a flag so the build machine uses the actual api. You get the best of both worlds: fast tests when developping, but you also validate that the api didn’t change. I just started a project monday that is gonna connect to 3 apis, so the presentation was very timely.

The second part was about a plugin he is developping called InactiveRecord to stub out the access to the database for your test. You can find the slides to his presentation along with the code here.

Second presentation was from Carl Mercier of Karabunga. It was a small tutorial on HAML, a templating engine for Rails. You can play online with HAML here. The latest version released a couple of weeks ago seems to have fixed a lot of performance problem (30% slower than rhtml instead of 1000% slower). I will have to give it another try soon, along with sass, which is haml for css.

Suggestions for improvements:

  • Bigger room for more people, but also more open space to make it easier to socialize, and a room where donuts are allowed ;)
  • Wiki on montrealonrails.com so people can post suggestions for topics that would interest them for presentations
  • Maybe we can have a round of quick presentation (2-5 mins) if let’s say you want to present a small plugin or a ruby trick. This could help orient discussions after the main presentation. It would also allow more people to talk and present themselves, in a less intimidating way than a full blown presentation.
  • Maybe someone is crazy enough to want to videotape the presentations?

I can’t wait for the next edition!

Popularity: 19% [?]

 

Capistrano is a framework for deploying Rails application (you can do more with it, but it comes with built-in tasks for rails). How does it work? It connects to the server through SSH, checks out the last version of your app from your subversion repository in a new directory (releases/{date}), runs migration (optional), symlinks the directory to /current. You’re up and running after simply running “cap deploy”.

It supports rollback when something goes wrong. Setup is really simple (for dreamhost, you can find info in the wiki). It supports more complex deployment scenarios to multiple machines (multiple app servers with one db server for example). It’s easily extensible if you need to add custom steps to your deployment procedure. Let’s say you have a directory for uploads, you can create a task to properly link to the new version.

It was my first time with Capistrano because I was working on Windows before. It is such a time-saver to have a great and powerful tool like this for deployment (compared to writing your own scripts). I think I’m in love.

Popularity: 12% [?]

 

I finally played a bit with the REST part of Rails. Over the weekend, I made my first RESTful web app. How did it go? I don’t know. I don’t think I’ve yet made the mental switch. There’s a few things that bug me about REST, and I’m not sure I can put it in words yet.

I think there’s “REST” and “Rails REST”. The way Rails does REST seem to be a subset of REST, or at least it puts more constraints on how you should do it.

The one thing that bothers me the most is the respond_to and how you can handle different formats. Yes it is nice to be able to reuse the same action and send back XML or CSV or a basic html representation of the information. But when it comes to the actual UI of your application, the html, the forms, the navigation, I don’t want my user to interact with the application the same way a machine would.

Maybe I should investigate a bit more the RADAR architecture as described by Dave Thomas. The idea is to have the html application be another layer on top of your resources.

Popularity: 3% [?]

 

Martin Fowler RailsConf 2006 Keynote Address

Very interesting speech.

Popularity: 7% [?]

 

For those of you who missed CUSEC, another keynote is now available at
SOENlive, this time the great keynote from Kathy Sierra. The first keynote “Rails is Boring and Ruby Is A Toy” from Chad Fowler is also available.

I have not posted much in the last few weeks. I’ve been busy learning Rails. I have convinced my company that it is the right choice for us. Six weeks later, everything is going smoothly. My nightmares about trying to add new features in ASP.Net have stopped. I’m having fun again developing software. I strongly suggest you try Rails if you’re having the blues at your job. It’s a great cure.

And now, the quote of the day:

A memorable quote from Kent was “Agile development does not mean never having to say you’re sorry”.

Rachel Davies: Beck on Responsibility

Popularity: 7% [?]