Active Record presentation at SNUG

Posted by Chris on October 03, 2006

Wednesday evening we had the last “SNUG”: meeting before summer. The meeting was hosted Dotway. We had a great turnout with around 30 people apart from us that arranged it, even though we informed about the meeting as late as two weeks earlier. First we had Jim Christensen from Commentor in Denmark tell us about the .NET Compact Framework and his experiences with mobile development. After that we had a break with Subway sandwiches and some great discussions. Finally I presented a session on the Active Record pattern that Martin Fowler describes in “P of EAA”:

I have uploaded a zip file with the C# examples that I showed. They show how the Active Record pattern works in it’s most simple implementation and then how to use Castle project’s ActiveRecord framework to avoid having to do all the work yourself.

I also showed an example of how a dynamic language such as Ruby can take this even further for extreme productivity gains. The code below shows how to use the ActiveRecord implementation in Ruby on Rails by itself in a simple script.

require 'active_record'

  :adapter => 'sqlserver',
  :host => '\SQL2005',
  :database => 'blogs',
  :username => 'blog_user',
  :password => 'secret')

class Blog < ActiveRecord::Base
  has_many :posts

class Post < ActiveRecord::Base
  belongs_to :blog

blog = = 'Chris Hedgate'
blog.uri = ''

post =
post.title = 'Hello, SNUG!'
post.contents = 'TBW'

blog.posts << post

blogs = Blog.find_all

blogs.each do |blog|
  puts "#{} (#{blog.uri})"

  puts 'Posts:'
  blog.posts.each do |post|
    puts " -- #{post.title}"

  puts ''

Finally, I promised to post some links to various things I talked about in the session.

* "Active Record pattern in P of EAA":
* "Data Mapper pattern in P of EAA":
* "Castle ActiveRecord implementation":
* "NHibernate": Object-Relational Mapper
* "NHibernate Generics":, Ayende Rahien’s nice contrib for working with generics
* Mats Helanders tool "ObjectMapper":

Thanks to all the people who attended the meeting. Kim, Daniel, Henrik and I look forward to seeing you at new SNUG meetings after the summer.


Trackbacks are closed.

blog comments powered by Disqus