Active Record

Intent: An object that wraps a record data structure in an external resource, such as a row in a database table, and adds some domain logic to that object.

See RubyOnRails implementation:

See DotNet implementation:

See PhpLanguage: implementation

Often one uses a database browser, such as Toad, to create and test queries. It may even be a DBA. If one then has to take these and convert them into an OOP notation, one is both wasting time on translation, risking translating it wrong, and making it harder to do the reverse: put the query back into the DB browser to change and analyze it or convert it into a Stored Procedure. It's the Double Shuffle.

For new, clean databases, it may not make much difference, but for databases that have been around a while and have built up historical oddities, it can be important to work with them in a DB browser.

Maybe this belongs in ObjectRelationalMapping? -- JeremyAube?

See also DataMapper, TransactionScript, TableModule, DataDictionary, HelpersInsteadOfWrappers

View edit of March 10, 2013 or FindPage with title or text search