Re: Mixing OO and DB

From: Gene Wirchenko <genew_at_ocis.net>
Date: Tue, 04 Mar 2008 16:01:51 -0800
Message-ID: <dhors3t759e20tkucosm15i5sa0hj1dupc_at_4ax.com>


Robert Martin <unclebob_at_objectmentor.com> wrote:

>On 2008-03-04 00:25:43 -0600, topmind <topmind_at_technologist.com> said:

[snip]

>> Um, like what if there are zero Bob's or 200 Bob's in the actual
>> system? Are you gonna arbitrarily pick one?
>
>Don't be silly. find("Bob") will either return the object for "Bob" or
>it will return nothing. You would only use this method if you knew
>that there could be no more than one "Bob".

     So if there is more than one "Bob", the method will return nothing?

>If there could be more than one "Bob", then you would use a function
>like: find_all("Bob") which would return a list of all the matching
>objects.

     The supposedly more complicated SQL uses the same query for each. Then, you check how many rows were returned. Writing two methods is simpler? Ah, no.

Sincerely,

Gene Wirchenko

Computerese Irregular Verb Conjugation:

     I have preferences.
     You have biases.
     He/She has prejudices.
Received on Wed Mar 05 2008 - 01:01:51 CET

Original text of this message