The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
Validate models using code, not annotations

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
David Heinemeier Hansson

Posts: 512
Nickname: dhh
Registered: Mar, 2004

David Heinemeier Hansson is the lead Ruby developer on 37signal's Basecamp and constructor of Rails
Validate models using code, not annotations Posted: Dec 26, 2004 6:31 AM
Reply to this message Reply

This post originated from an RSS feed registered with Ruby Buzz by David Heinemeier Hansson.
Original Post: Validate models using code, not annotations
Feed Title: Loud Thinking
Feed URL: http://feeds.feedburner.com/LoudThinking
Feed Description: All about the full-stack, web-framework Rails for Ruby and on putting it to good effect with Basecamp
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by David Heinemeier Hansson
Latest Posts From Loud Thinking

Advertisement

Berin Loritsch is thinking about how to validate his domain models in Java. He's on the right track with his intention to shun the XML morass so commonly sought by the J-people, but unfortunately his ambitions stop short. He seems to be content with merely annotating his models with the validation rules instead of actually embedding them in code.

If he were using Rails, he'd be able to enjoy specifying validation rules using actual code in his Active Record objects. The following is not even a mock-up, I literally yanked part of the Account model in that next project I'm working on:

class Account < ActiveRecord::Base
  validates_presence_of     :subdomain, :name, :email_address, :password
  validates_uniqueness_of   :subdomain
  validates_acceptance_of   :terms_of_service, :on => :create
  validates_confirmation_of :password, :email_address, :on => :create
end

To me, this is beautiful. Programming poetry. Each method call reads like a sentence. "Account validates acceptance of terms of service on create". How can you not love that?

So please, aim higher. Annotations are a work-around for type system thats holding you back. Let it go. We'll be happy to help you transition out of the Sun and into the shade. Come join us in the Ruby on Rails community.

Read: Validate models using code, not annotations

Topic: Geek Birthday Humor Previous Topic   Next Topic Topic: Rubyist Magazine 3

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use