RailsConfEurope: The One-Two Punch – JQuery with Rails

Next session wasThe One-Two Punch: jQuery with Rails by Yehuda Katz of EngineYard. Yehuda has done a lot of work of integrating the JQuery javascript library with Rails, so it becomes a viable alternative for Prototype (the default library in Rails).

JQuery is basically a simple javascript framework for getting dom elements and do some stuff with it. Core to this are CSS3 like selectors (e.g. div:not(#foo), div:contains(txt), div:empty, ) plus some own (e.g. div.has(p)). Some useful css2 like selectors (e.g. div[foo!=bar], checkt attribuut waarde). Some are pseudoselectors, but very useful and powerful.

The selectors return a jQuery object. The same functions can be applied to this object (if it is an element, array of elements etc.) -> this is not the case in Prototype.

JQuery has 5 parts: dom manipulation, events, ajax, effects, plugins.

Seems like a really nice library and a good alternative for prototype.js. The dom manipulation and ajax stuff seems a lot simpler and the plugins option is really nice.

The Rails helpers use a really nifty trick. They add a metadate attribute to the html element (e.g. an input) and then the Ajax javascript handler can access that (e.g. url, model id etc.)
Another interesting library that was mentioned was livequery. Have to look into that. Seems to be a set of Rails helpers.

Resources

Slides: will be available on the site

RailsConfEurope: Keynote DHH – Living with legacy software

The keynote of David Hennemeijer Hanson this morning was not really about technology, but more about us developers using the technology (in this case Rails). He made a good point about legacy software: that it’s more an opinion of us, than a property of the software itself and that it’s a reason to celebrate when we consider our software legacy: we have learned and grown as software developers.

Not really easy to summarize the session right now, but when I have the slides I will try to summarize the session because it was quite good (it made me think differently about legacy software) and David had some nice examples of how he refactored the Basecamp codebase (the flagship product of 37signals).

RailsConfEurope: Meta-programming ruby for fun & profit

The second tutorial I followed was a tutorial called ‘meta-programming ruby for fun & profit’ by Neal Ford of Thoughtworks.

Quite interesting stuff, a bit complex though. Will have to study this again with the slides at hand to really understand this level of meta-programming. When I do I might write another post on this session and topic :)

Slides: www.nealford.com under conferences

RailsconfEurope: Accessible Ajax on Rails

First day at RailsConfEurope in Berlin!Following a tutorial on Accessible Ajax on Rails now by Jarkko Laine.

Accessible Ajax on Rails
View SlideShare presentation or Upload your own. (tags: rails ajax)

Jarkko started with an explanation of the need for unobtrusive javascript. It basically boils down to separating your javascript from your html into a separate javascript file (like you separate your styling from your html in a separate css file). That has a couple of benefits: cleaner design, separation of concerns and a more accessible website (if you take a bit of extra care, the website will also works without javascript).

The tutorial part started with a simple todo list application that used the standard Rails Ajax helpers (e.g. link_to_remote) . Problem with these Rails helpers is that they are not unobtrusive (they generate a lot of javascript code throughout your html code = no separation of concerns) and your site doesn’t work anymore when javascript is turned off (or is not supported).

Jarkko then showed how to separate the javascript from the html (like separating styling in a css file) and reattach it with css selectors with a really nice javascript framework for unobtrusive javascript called Lowpro. Lowpro is based on the Prototype javascript library that comes with Rails.

I first heard about the Lowpro library at the RailsconfEurope in London, 2006. Since that time, the LowPro library seems to have grown up.

Especially the Behavior classes are a really nice way to structure event handling code a bit more “object oriented”. These Behavior classes play the role of the controller in the MVC pattern used in Rails, but then for the client side javascript code.

Lowpro also has a niceset of default behavior classes (e.g. for a remote form).

The concept of event bubbling and event delegation was a nice eye-opener for me. This allows you to add a behavior to a top level element (e.g. an ul) and then delegate the event to a child (e.g. a li). This way you don’t always have to use reload the behaviors after an ajax call (when you only update the childs of course!). Lowpro has nice methods for all this off course. There are some problems with event delegation though: not all events bubble up (most notably focus and blur) and it can kill performance in somce cases (notably onmouseover).

Definitely worth learning more about. I will try to use it in my work projects and a project I am working on now in my free time (a community where people can share physical stuff with their friends, neighbours, colleagues etc.) but more on that in a later post.
Resources:

Presentation on SlideShare: http://www.slideshare.net/supervillain/accessible-ajax-on-rails-presentation
Lowpro svn repo: http://svn.danwebb.net/external/lowpro/trunk/
Tutorial code: http://github.com/jarkko/unobtrusive_book_code/tree/

Leaving for Railsconf Europe 2008 in Berlin

Together with a colleague I am leaving now for RailsConf Europe 2008 in Berlin! We will be driving there by car and return next thursdag night.

We hope to meet a lot of interesting people at the conference and learn a lot about the newest in Ruby on Rails.

Pownce – a signup proces that made me smile :)

Today I signed up for an account at pownce.com and was surprised by a little joke that made me smile:

Pownce - signup made me smile :)

It made signup up for yet another account a bit less annoying.

Why don’t all new webapps support OpenID? Then I can use my OpenID account anywhere and I never have to signup up for yet another account anymore. The only downside of this would be that I would have missed this little joke then :)

The Starfish and the Spider

Currently I am reading “The Starfish and the Spider, the Unstoppable Power of Leaderless Organizations” by Ori Brafman and Rod Beckstrom. It’s a really interesting book on how people can organize themselves as a group without a traditional leadership hierarchy. The authors compare such organizations with starfish. When you cut a starfish’s legs off, the leg will grow into a new starfish. When you cut off a spider’s head it will die.

In a starfish organization everyone has equal powers and there is no leader. At first one might think that this will cause anarchy, but a starfish organization has a couple of characteristics that prevent this. Out of the chaos, creativity will arise and the organization will be very resilliant to change.

Some famous examples of starfish organizations in the book are the Apache indians, the AA (Anonymous Alcoholics) organization, Wikipidia, Napster and Kazaa. Open source development projects tend to be organised as starfish too.

Edible flowers

DSC02846This spring I cleared a small spot in or small garden to grow our own vegetables. It was quite a success and a lot of fun! We had cabage, tomatoes, purple potatoes (trifle potatoes), reddish, carrots and edible flowers.

Every time we invited friends for a home made diner the edible flowers were a big success. In this picture you see nice a dish we made with ‘Oost indische kers’ (I don’t know the english name for them). The first time you eat a flower is a bit strange, but they taste really good, quite unlike anything you have eaten before actually (sweet, spicy and flowery :) ).

« Previous Page