This is a design pattern we all being using for sometime, sometimes without knowing this is a design pattern.
Martin Fowler describes Active Record as;
An object that wraps a row in a database table or view, encapsulates the database access, and adds domain logic on that data.
Active record is an approach to accessing data in a database. A database table or view is wrapped into a class, thus an object instance is tied to a single row in the table. After creation of an object, a new row is added to the table upon save. Any object loaded gets its information from the database; when an object is updated, the corresponding row in the table is also updated. The wrapper class implements accessor methods or properties for each column in the table or view.
This pattern is commonly used by object persistance tools, and in object-relational mapping. Typically foreign key relationships will be exposed as an object instance of the appropriate type via a property.
1. Castle Project Active Record an open-source Microsoft .NET Implementation
2. Dunn & Churchill Diamond Binding a commercially supported Microsoft .NET Implementation
3. Ruby on Rails contains a Ruby implementation of Active Record.
4. Subsonic Project contains a .NET implementation of Active Record.
5. Akelos PHP Framework contains a PHP version of Rails Active Record.
6. Cake PHP contains a PHP implementation of Active Record.
7. Elixir is a Python implementation of Active Record.
8. Grails contains a Groovy implementation of Active Record.
Castle and Diamond Binding both have excellent (and similar) APIs, if you are doing any database access in .Net without using one of them you are missing out. Castle is probably the best open source implementation there is. Diamond Binding is commercial, but great value (around $500). It does everything Castle does, but also supports generics and has a really cool VS2005 addin that synchronises your class defintions so you don't have to do any mapping by hand.
ReplyDeleteThey both use NHibernate under the hood as well, so they are both reliable and fast. Faster than any custom data layers or code generation - the query optimisation is fantastic. I think NHibernate is around 15 years old now, so thats definitely mature :)
I think DB is free for non-commercial use too actually.
Thanks a lot for your comment.
ReplyDelete