Re: Mixing OO and DB
Date: Thu, 6 Mar 2008 13:54:30 -0800 (PST)
Message-ID: <60a4ba94-4ec6-4bcc-a3c9-04130bd7662e_at_i12g2000prf.googlegroups.com>
Robert Martin wrote:
> On 2008-03-02 13:28:28 -0600, frebe <frebe73_at_gmail.com> said:
>
> > On 2 Mar, 20:01, Robert Martin <uncle..._at_objectmentor.com> wrote:
> >>
> >>>> � Employee e = Employee.find("Bob"):
> >>
> >>>> � DataRow e = exec("Select * from EmployeeTable where name = 'Bob';);
> >>
> >>> Why is the first line better than the last line?
> >>
> >> It's smaller, more communicative, and can be polymorphically deployed.
> >
> > Both are one-liners.
>
> True, but most forms of the top line will remain one-liners even when
> the SQL grows to many lines.
If such grows too big, I too may "functify" it, or at least portions of it.
[snipped arguments addressed elsewhere]
> >> All we are doing is giving each query a name. �That name
> >> is the name of the method that is implemented by the SQL. �This allows
> >> the programmer to commnicate the *intent* of the query, rather than
> >> it's implementation.
> >
> > What stops you from creating views when suitable?
>
> Nothing.
Actually, the DBA sometimes does, but view access rights is another story.
> >>> What is the benefit with hiding SQL from the bulk of the application?
> >>
> >> You can provide test implementations that don't use the database, but
> >> allow you to quickly test business rules.
> >
> > If the business rules (eligible_for_retirement) is in the database,
> > the test would be pretty useless.
>
> The business rule is not the query. The business rule is what is done
> with the results of the query. For example, I want to test that I can
> send email to all the eligible employees, and format that email nicely
> with their name, employee number, years of service, etc. The query is
> irrelevant to the job of creating and sending the emails.
>
> --
> Robert C. Martin (Uncle Bob)��| email: unclebob_at_objectmentor.com
> Object Mentor Inc.� � � � � ��| blog:��www.butunclebob.com
-T- Received on Thu Mar 06 2008 - 22:54:30 CET