Re: Mixing OO and DB

From: Robert Martin <unclebob_at_objectmentor.com>
Date: Sat, 8 Mar 2008 20:14:01 -0600
Message-ID: <2008030820140138165-unclebob_at_objectmentorcom>


On 2008-03-06 15:54:30 -0600, topmind <topmind_at_technologist.com> said:

>> 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.

>
> What do you mean, it would likely select WHICH employees are included?
> How is that *not* part of the biz logic? That is at LEAST as
> important as the formatting.

It's not about importance. Of course the query is every bit as important as the rule. It's just that the query and the rule need not be coupled.

e.g.

slaggards = find_slaggards();
fire(slaggards);

Note that the query and the rule work nicely together, but are separate. The query could have been used with a different rule:

slaggars = find_slaggards();
list(slaggards);

And the rule could be used with a different query.

expensive_employees = find_expensive_employees(); fire(expensive_employees);

> And again, one could have a DB of test cases to make sure our
> filtering works as intended. Otherwise, we might send a very fancy and
> shiney TERMINATION notice to the WRONG employees, and they'd have to
> go do something new, such as become OO book authors :-)

And we often do have separate DBs of test cases. However, that's not always (or even usually) the most practical solution.

-- 
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 Sun Mar 09 2008 - 03:14:01 CET

Original text of this message