RESTful Everything - Towards a Complete Resource-oriented Workflow

Ingo Weiss (adva Business Software)
14:30 Wednesday, 3-09-2008
General
Location: Salon 4
Average rating: ***..
(3.48, 21 ratings)

The problem

When using RESTful routes, developers do not need to figure out what actions controllers should have, how to name them and where to put them. For all this there are conventions. When naming helpers and CSS classes, however, developers and designers are still on their own. The best developers will manage to give their helper suite a DSL-like consistency and expressiveness, but especially on large projects with many developers, names are often times made up in a ad-hoc fashion when and where they are needed, duplication and inconsistencies are likely to creep into the code, and non-semantic classnames into the markup and stylesheets.

What worked for us

In my talk, I will present a modest, simple pattern that we are successfully using at twinity.com, establishing resource-oriented conventions for naming of helpers and css classes, toward what is essentially a full resource-oriented workflow, with routes, controllers, views, CSS and JavaScript all speaking the language of resources:

  1. All our links and foms are given standard CSS classes that combine a noun (the resource name) with a verb (a CRUD action).
  2. The links an forms are created using helpers that are themselves named with a combination of a resource name and the CRUD action they are triggering.

As simple as this pattern is, it has great benefits downstream, such as:

  • A rich set of CSS classnames readily available for elegantly targeting elements in CSS sheets and javascripts, greatly reducing the need to come up with custom classnames
  • Near-perfect separation of presentation and semantics
  • Shared resource-oriented vocabulary between developers and designers, leading to improved communication
  • Many more possibilities for designers to give elements default styles and behaviors that just work out of the box for rapid development and prototyping with late and minimal designer involvement.
  • A consistent story running through the entire MVC stack – and it’s the story of your application’s functionality!

Real-world examples

I will then walk through practical examples of how the resource-oriented naming pattern allowed us to:

  • Write more compact, yet expressive views
  • Use contextual selectors to write more elegant, expressive CSS
  • Use CSS3-selectors to elegantly declare application behavior in LowPro behavior sheets
  • More effortlessly navigate the DOM tree in LowPro behaviors and other dom scripts.

The plugin

To wrap it up, I will introduce our plugin (due to be released in April) for generating resource-oriented helpers

Photo of Ingo Weiss

Ingo Weiss

adva Business Software

Ingo Weiss is lead developer at Metaversum(twinity.com) in Berlin, Germany. Before that, he designed and built web applications and interactive educational experiences at WGBH, Catapult Thinking, and as a consultant in Boston, USA. He also taught Interaction design and Rails application development, among other classes, at Northeastern University.

News and Coverage
co-presented by Ruby Central, Inc. O'Reilly
  • Engine Yard
  • Sun Microsystems
  • Brightbox
  • ELC Technologies
  • T3N

Sponsor Opportunities

For information on exhibition and sponsorship opportunities at RailsConf Europe, contact Yvonne Romaine at yromaine@oreilly.com

Press and Media

For media-related inquiries, contact Maureen Jennings at maureen@oreilly.com.

Contact Us

View a complete list of RailsConf Europe Contacts