Re: Mixing OO and DB

From: Robert Martin <unclebob_at_objectmentor.com>
Date: Mon, 11 Feb 2008 10:11:12 -0600
Message-ID: <2008021110111250073-unclebob_at_objectmentorcom>


On 2008-02-07 14:35:26 -0600, Victor Porton <porton_at_narod.ru> said:

> I know both object oriented programming and DB (SQL). But it seems
> that these are incompatible. Or may somebody advice how to meddle them
> together?

The concepts are orthogonal. Objects are not tables. Tables are not objects. The many efforts to try to force tables and objects together always cause trouble. Things work better when you recognize the benefits of tables, and the benefits of objects, and use each where they belong rather than try to force one to use the other.

Tables expose data and have no behavior. Objects hide data and expose behavior. These two descriptions are very nearly opposites of each other. OO is a technique for organizing the dependencies between source code modules in order to minimize the impact of change. DBs are a technique for representing data in a formal and consistent fashion.

Learn each. Appreciate each. Apply each. Keep each where it belongs.

-- 
Robert C. Martin (Uncle Bob)  | email: unclebob_at_objectmentor.com
Object Mentor Inc.            | blog:  www.butunclebob.com
The Agile Transition Experts  | web:   www.objectmentor.com
800-338-6716                  |
Received on Mon Feb 11 2008 - 17:11:12 CET

Original text of this message