personal experiences and code :)

Wednesday, October 11, 2006

RIFE - as DRY as it comes

Aral has a post on some DRY pains with RoR ( aral's blacklist of ips also managed to scoop me in, so my comment could not be retained

anyways, Aral, I feel your pain; I don't know enough about Ruby or RoR to give a meaningful suggestion wrt them; in the RIFE community ( though, we believe that centralizing the metadata for your business objects, and allowing that to drive all the other connecting layers of your application is quite RIFE (read kewl ;P)

say you have an object instance of Foo, foo, where

Foo { String name; String email; }

the metadata facility allows you to say, for example:

addConstraint(new ConstrainedProperty("name").notNull(true).notEmpty(true));
addConstraint(new ConstrainedProperty("email").email(true).unique(true).maxLength(100));

the email field could, for instance, be representing the login field in your authentication toolkit

by defining such metadata for the email field, the framework is able to (among a whole load of things):

* through it's database layer, use an sql query builder to limit the size of the column in which the text will stored when the table creation sql is generated (by the framework for you, from your business object/bean),
* through the metadata facility, validate/check that data entered indeed conforms to those constraints: that it's a well-formed email address, that it is unique (by applying a datasource context to it) and that it's size does not exceed the size constraints applied to it.
* through it's template engine, use an html form builder to create a field that doesn't allow the entry of longer text
* through it's template/validation engines, generate meaningful, customizable (through properties) error messages when constraints have been violated.

these, to paraphrase Steven Grimm, "cross-layer synergies" (enabled by RIFE's centralized metadata facility) are some of the reasons we are seeing an influx of developers adopting the RIFE way.. I don't believe it gets DRYer (or RIFEr for that matter) than that ;)

-- eokyere :)

No comments: