Re: Decouple SQL queries from class in OOP design



On 18 Nov 2005 23:31:00 -0800, "topmind" <topmind@xxxxxxxxxxxxxxxx>
wrote:

>
>Robert C. Martin wrote:
>> On 9 Nov 2005 21:59:18 -0800, "topmind" <topmind@xxxxxxxxxxxxxxxx>
>> wrote:
>>
>> >SQL in code is not evil[1].
>>
>> Agreed. SQL is not evil. But combining it with business rules is
>> inadvisable.
>
>In a good design, most of the code should be business rules. If it is
>GUI management, for example, then you are not using the appropriate
>libraries/tools/languages. You are not coding to the domain but wasting
>code on technlogy issues or the like rather than spending code on
>solving the problem at hand.

A huge amount of effort goes into mapping business data into
presentation formats. This mapping is not a business rule, per se;
but is still complicated and important code that needs to be written.
It should be separate from the business rules.

Similarly, there is often a large amount of effort that goes into
mapping the business data into a persistent repository (i.e. a
database) that is accessible and usable by many different
applications. Once again this mapping is not a business rule, per se;
but is still complicated and important code that needs to be written.
It should be separate from the business rules.




-----
Robert C. Martin (Uncle Bob) | email: unclebob@xxxxxxxxxxxxxxxx
Object Mentor Inc. | blog: www.butunclebob.com
The Agile Transition Experts | web: www.objectmentor.com
800-338-6716


"The aim of science is not to open the door to infinite wisdom,
but to set a limit to infinite error."
-- Bertolt Brecht, Life of Galileo
.



Relevant Pages