Re: Mixing OO and DB
Date: Sun, 2 Mar 2008 13:38:37 -0600
Message-ID: <2008030213383743658-unclebob_at_objectmentorcom>
On 2008-02-28 19:05:51 -0600, topmind <topmind_at_technologist.com> said:
The mapping is coded in source modules, of course. However, the main
>> 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.
>
> No it doesn't because the mapping has to be coded *somewhere* anyhow.
>> 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.
>
> But it is not "upping" the abstraction enough to justify all the
> method proliferation.
Sure it is. find_eligible_employees is at a higher level of abstraction than select * from ... and ... where ... < ... or ... ... ... ;
The calculation has a *meaning* or intent; and the method provides the name of the intent.
>>> If you have a lot of find_by_xxx methods, swapping would still be >>> quite difficult. >> >> That is true. In my experience there isn't usually a >> proliferation of such methods because traversal is done by object >> reference rather than by some subset of object state.
>
> In other words, your app reinvents a (navigational) database in the
> app. You can query the DB less because your app becomes a (half-ass)
> DB.
Not quite. The app because an *application specific* DB. That's not half-assed at all.
> OOP 101:
>
> 1. RDBMS are Satan.
-- 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 02 2008 - 20:38:37 CET