Re: Mixing OO and DB

From: Robert Martin <unclebob_at_objectmentor.com>
Date: Mon, 3 Mar 2008 19:29:11 -0600
Message-ID: <2008030319291151816-unclebob_at_objectmentorcom>


On 2008-03-03 08:20:58 -0600, "Dmitry A. Kazakov" <mailbox_at_dmitry-kazakov.de> said:

> On Sun, 2 Mar 2008 12:47:41 -0600, Robert Martin wrote:
>

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

>
> Employees ("Bob")
>
> But, select yields a set _{e}_, find does an element _e_ of. Implicit
> casting {e} <-> e is a very bad idea. Type systems are to prevent such
> things.

Indeed. A function can easily and implicitly communicate that the result will have one, and only one, member.

                Employee e = get_employee("Bob");

-- 
Robert C. Martin (Uncle Bob)  | email: unclebob_at_objectmentor.com
Object Mentor Inc.            | blog:  www.butunclebob.com
The Agile Transition Experts  | web:   www.objectmentor.com
800-338-6716                  |
Received on Tue Mar 04 2008 - 02:29:11 CET

Original text of this message