Re: Mixing OO and DB

From: topmind <topmind_at_technologist.com>
Date: Fri, 29 Feb 2008 11:29:11 -0800 (PST)
Message-ID: <a00d1ca1-85bc-4dad-bc9b-97cf27a0f979_at_s13g2000prd.googlegroups.com>


Patrick May wrote:
> frebe <frebe73_at_gmail.com> writes:
> >> >> We still have it, and we still use it. But we also hide it from
> >> >> the bulk of the application.
> >>
> >> > What is the benefit with hiding SQL from the bulk of the
> >> > application?
> >>
> >> For one thing, it decouples the application code and the
> >> database schema.
> >
> > And the benefit with decoupling application code and database
> > schema, is?

>

> You've asked this before and it has been fully answered. The two
> components change at different rates for different reasons, especially
> in distributed applications and when the database supports multiple
> applications.

In my experience, they often change for the *same* reason at the same time.

>

> >> For another, as noted by Mr. Martin, it allows the creation of a
> >> domain specific language that better reflects the concepts in the
> >> problem and solution domains.
> >
> > What created language are you talking about, the API?
>

> I'm referring to the classes and associated methods that reflect
> the problem and solution domains. It is more understandable to
> provide an interface like:
>

> VaR var = portfolio.calculateVaR();
>

> than it is to use SQL to retrieve in all of the positions associated
> with a portfolio and all of the time series data associated with each
> position, then perform a complex calculation on each set of time
> series data, and finally aggregate the results and perform a final
> calculation to get the portfolio VaR.

In my opinion, *repetition* in usage should be the primary determinant as to whether one should wrap a segment of code in methods/routines or leave it be. Wrapping merely for *documentation* purposes is poor form. We have *comments* for those:

 // retrieve portfolio
 pf = query("select x from foo where.....");

In the past, some have complained that comments can get out of date. But, so can routine names.

> Regards,

>

> Patrick

>

-T- Received on Fri Feb 29 2008 - 20:29:11 CET

Original text of this message