Re: Mixing OO and DB

From: topmind <topmind_at_technologist.com>
Date: Mon, 3 Mar 2008 08:38:36 -0800 (PST)
Message-ID: <1e38fe07-1509-41b8-9df5-32771cec8da1_at_i12g2000prf.googlegroups.com>


Robert Martin wrote:
> On 2008-02-28 10:36:03 -0600, topmind <topmind_at_technologist.com> said:
>
> >
> >>
> >> Of course we can implement other kinds of 'find' methods.
> >> find_by_date, find_by_salary, etc, etc. Every different query we use
> >> on a regular basis, we can create a verb for in our DSL. That verb is
> >> a function call of some kind.
> >
> > Such only makes sense if you do the same kind of query in *multiple*
> > spots. One-usage wrappers are a waste of code in my opinion and just
> > creates tedious red-tape accessor clutter.
>
> Not if they are explanatory.

Like I suggested elsewhere, use *comments*. Using methods/functions in place of comments is not economic, and makes the code unnecessarily cluttered with micro-methods, making it harder to find the "meat" methods. I cannot vouch for every eyeball out there, but it slows down my reading to have all that extra junk in there.

> Employee.find("Bob") is a lot easier to
> understand than Select * from Employee_Table where Name = 'Bob';

> In
> any case, once you have the method, you can polymorphically replace it
> with test methods etc.

We already discussed testing techniques. I don't think we need to reinvent that argument here again. I like my approach and you like yours and we probably won't change anybody's mind. If you can show objective improvement without significant downsides, I'll take a second look.

[snipped similar testing claims]

>
> --
> Robert C. Martin (Uncle Bob)��| email: unclebob_at_objectmentor.com
> Object Mentor Inc.� � � � � ��| blog:��www.butunclebob.com

-T- Received on Mon Mar 03 2008 - 17:38:36 CET

Original text of this message