Re: OO and relation "impedance mismatch"

From: mAsterdam <mAsterdam_at_vrijdag.org>
Date: Sun, 03 Oct 2004 22:04:13 +0200
Message-ID: <41605b3d$0$48933$e4fe514c_at_news.xs4all.nl>


Gene Wirchenko wrote:

> mAsterdam wrote:

>>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.
> 
>      Why is it not necessary for data to be consistent at the object
> level?  (Or another way:)  Why is it acceptable for data to be
> inconsistent at the object level?

Nice question.

Maybe an example helps.

A user, busy updating some data, has a screen full of them. Phone rings, he answers and after the call he decides to get a cup of coffee. The stuff on his screen (data in screen-widget objects) may or may not be consistent with the tables now: some other user may have changed (part of) it while he was away. The data on the screen may be outdated.

It may be a nuisance for the user that his changes will not be accepted, but at no time the integrity of the system was violated, despite the fact that there may have been contradictory data (screen vs database , or window 1 vs window 2) at some time.

A critical monitoring application might issue timely screen refreshment, precisely to address this.

That leaves "is it acceptable for data to be inconsistent at the object level?" interpreted as 'is it acceptable to have contradictory data in an object?'

Tough one. I'll try - don't hesitate to chime in :-)

Contradictions relevant to the behaviour of the object need to be resolved, of course.

One problem is: You can't tell. Because of the data is encapsulated you are not supposed to know how many redundant representations of the very same fact are in your object at any time, or wether they are in sync.
Mechanisms should be in place to disambiguate before the contradiction could affect behaviour (such affected behaviour would constitute a bug, interestingly not the contradiction by itself).

A sense of neatness suggests objects should have consistent data, so to avoid any contradictions

  • but it is not as important as contradictions (or even just wrong data: lies) in the database.

In short: I think it is acceptable because the contradictions are local and temporary - but I'ld like to see arguments showing why it should not be. Received on Sun Oct 03 2004 - 22:04:13 CEST

Original text of this message