From: Aredridel Date: 2004-01-11T01:06:02+09:00 Subject: Re: Database applications and OOness On Fri, 2004-01-09 at 16:28, David Heinemeier Hansson wrote: > I've build an implementation of Martin Fowler's ActiveRecord pattern > [1] with support for single-table inheritance [2]. It's designed with > the notion of "Convention Over Configuration", which basically means > that you follow a set of naming conventions to get a bunch of behavior > for free. Best to show with an example: Whoa, me too -- I came up with it while coding an MVC-structured web app this week. My code works like so: class Foo < SQLObject key_field :id field :name field :amount field :date field :quantity calculated_field: total end and there's a get, put & find method. field defines accessors for the values, and sets up an array of fields in the class instance. The table that this comes from is defined to be class.name.lower+'s' -- overridable by overriding the class' table method. It works well for me -- it hides enough of the SQL to be "OO enough" for me, and lets me use inheritance to show relation. Ari