Re: OOP - a question about database access

From: Tim (nocomment_at_rogers.com)
Date: 11/08/03


Date: Sat, 08 Nov 2003 16:55:06 GMT

Uncle Bob (Robert C. Martin) wrote:
> Tim <nocomment@rogers.com> might (or might not) have written this on
> (or about) Sat, 01 Nov 2003 19:07:46 GMT, :
>
>
>>What happens when the data already exists from some other application?
>
>
> Ignore it until you know what your classes and objects are, and then
> fine a way to bind the existing data to those objects.
>
>
>>Don't you have to develop applications where at least some of the data
>>already exists?
>
>
> Yes, all the time.
>
>
>>It's nice to talk about object this and object that but the bottom line
>>is, the data resides on databases, for the most part, and you better be
>>able to produce applications that can access that data and produce the
>>results the boss wants.
>
>
> Absolutely. However, the other bottom line is that you must be able
> to produce systems that respond well to changing requirements. It is
> difficult to do this when the structure of the database has
> infiltrated all the code. So we try to keep the two very separate.
>
>
>>Do you tell the president of a bank that the databases he has with
>>customer banking information may have to be completely reorganized
>>depending on your object oriented analysis for some reporting system or
>>do you make your system fit the data, if possible?
>
>
> The latter; but only in the interface layer. On the application side
> we have objects that suit the application. On the database side we
> have tables that suit the data. In between we have an interface layer
> that translates one form to the other.
>
>
>>All this theory is nice but it ain't gonna fly in the real world that I
>>live in.
>
>
> The separation of database and application is not theory. It is a
> pragmatic technique to protect business rules from database structure.

Thanks for the reply. So what I think I'm hearing is that I should keep
the data access to one or some separate objects whose methods can be
accessed by the applications business objects. These (data access)
objects can then be changed when the databases change without affecting
the business logic portion of the system. These objects have methods
that return the data in a form that is needed by the business objects.
These data access objects would access the tables and do any kinds of
translations or multiple table look ups to put the information into the
format desired by the business objects. Please forgive my non-OO
terminology.
The problem I had was people never seemed to mention, or I wasn't
grasping, the idea of the interface layer.

>
> Robert C. Martin | "Uncle Bob"
> Object Mentor Inc. | unclebob @ objectmentor . com
> 501 N. Riverside Dr.| Tel: (800) 338-6716
> Suite 206 | Fax: (847) 775-8174 | www.objectmentor.com
> | | www.XProgramming.com
> Gurnee, IL, | Training and Mentoring | www.junit.org
> 60031 | OO, XP, Agile, C++, Java, C# | http://fitnesse.org



Relevant Pages

  • Re: OOP - a question about database access
    ... >the data access to one or some separate objects whose methods can be ... >that return the data in a form that is needed by the business objects. ... We call such objects Database ... You can read about the proxy method in "Agile Software Development: ...
    (comp.object)
  • Re: OOP - a question about database access
    ... >>the data access to one or some separate objects whose methods can be ... >>that return the data in a form that is needed by the business objects. ... We call such objects Database ... Martin Fowler wrote about several similar techniques in his ...
    (comp.object)
  • Re: Subject:Writing a db independent data access layer with DAAB:How?
    ... > was researching how i can write a database independent data access layer. ... > be able to work both in SQL and Oracle. ...
    (microsoft.public.dotnet.framework.adonet)
  • Looking for a decent data access architecture to implement
    ... application so that there is a clean separation between the data access ... layer, the business layer and the GUI layer. ... the actual database. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Change Connection String at runtime.
    ... exposes custom objects that are implemented to use the custom data access ... easily moved to another database, or have versions for each database. ... and protocols each data source exposes. ... connection string to the connectionobject before the connection opens. ...
    (microsoft.public.dotnet.framework.adonet)