Re: Mixing OO and DB

From: Robert Martin <>
Date: Sun, 24 Feb 2008 09:12:18 -0600
Message-ID: <2008022409121816807-unclebob_at_objectmentorcom>

On 2008-02-22 17:41:58 -0600, topmind <> said:

>> Actually, I think you have already named some examples.  Using a dummy
>> database for testing, for example.  Not that you MUST use OO for these
>> things; but often you can, and often it is convenient.

> Well, I think that is stretching the definition of OOP a bit far,
> almost like saying word-processors are OOP/polymorphic because they
> can open any document of a given extension. That's all the test DB is
> like: we simply point the app to a different (test) DB just like a
> word-processor or Excel opening a different document.

Actually, I think there's a fundamental difference. In the word processor there is a if/else or switch statment that hands control off to the appropriate file parser. It goes one way for a .doc and another way for a .rtf. That's not an OO concept.

On the other hand, when you substitute a dummy database for a real database, there is no if/else or switch statement that routes flow of control differently. The application does not know that a dummy database is in use. That is much closer to an OO concept.

Now, if we take that one step further, and swap in a dummy database engine, and have the application access it through a polymorphic interface, we have true OO.

Robert C. Martin (Uncle Bob)  | email:
Object Mentor Inc.            | blog:
The Agile Transition Experts  | web:
800-338-6716                  |
Received on Sun Feb 24 2008 - 16:12:18 CET

Original text of this message