Re: OO and relation "impedance mismatch"

From: mAsterdam <mAsterdam_at_vrijdag.org>
Date: Sun, 03 Oct 2004 11:10:43 +0200
Message-ID: <415fc213$0$14941$e4fe514c_at_news.xs4all.nl>


Fredrik Bertilsson wrote:

> ... OO purists are claiming that the object model
> should be design before the (or without respect to)
> the database schema.

This is a development process issue. It may matter wether (parts of) the object-models are designed before, after or simultaneously with the database. ISTM all three plans seem viable, as long as the different designs get appropriate attention, and appropriate cross-checking.

> ... I would make (or generate) one class for each table
> and use SQL queries for retrieving records/objects.
> Why can't tables and records be considered as "objects"?

They are different things, they serve different purposes. The tables hold data (meaningful in their own right), the objects behave, only need data to do what it is they are supposed to do.

The data in your tables need to be consistent with eachother at any point in time. This restriction is not necessary at the object level and may be perceived more as a hindrance than as a feature for the objects. During its life the object only needs data necessary for its required behaviour.

Only when an object needs to be remembered after it dies (for a possible next incarnation), all data necessary for it's later revival must get out of the (object-context of) the running program into the database. However, truths from the restricted environment of the running program no longer hold. Implicit assumption "the rest of the world will stay the same during the life of my object" suddenly backfires: consistency with the rest of the database is required.

OTOH an OO-program may have a coffin or fridge class to encapsulate what it perceives as the tables' tasks. Received on Sun Oct 03 2004 - 11:10:43 CEST

Original text of this message