Re: Decouple SQL queries from class in OOP design



Robert C. Martin wrote:
> On 9 Nov 2005 17:35:50 -0800, "Hongyu" <forward@xxxxxxxxxx> wrote:
>
> >To my knowledge, in OOP design it's not good to mix SQL queries with
> >application codes in classes, because it limits the usability of the
> >classes and bound them to the local database schema.
>
> Indeed, it is not good to mix SQL with business rules in *any*
> paradigm. You'd like your business rules to know nothing of SQL.
> You'd also like your business rules to know nothing of the relational
> schema. The business rules want to use a convenient set of data
> structures (or objects).

Cool. When I forget my badge and show
up at the front door and give them my employee ID, it is sure nice not
to have an
EMP table and query it directly, but send a message to each and every
DEPT
instance to ask "does emp 1234 work for you?"

This funny interface separation idea is one of the reasons why data
mangement folks call OOP crowd incompetent.

.



Relevant Pages

  • Re: Decouple SQL queries from class in OOP design
    ... in OOP design it's not good to mix SQL queries with ... because it limits the usability of the ... it is not good to mix SQL with business rules in *any* ... You'd like your business rules to know nothing of SQL. ...
    (comp.object)
  • Re: Sql / Dot Net General Discussion
    ... have some sql skills but they are limited. ... to enforce, in a database, a large number of business rules that are unrelated ...
    (microsoft.public.dotnet.general)
  • Re: Critique of Robert C. Martins "Agile Principles, Patterns, and Practices"
    ... since all the SQL is concentrated in one place rather than spread out and duplicated. ... From my point of view it is significantly less since I can forget about the SQL and Schema while dealing with the business rules and interface. ... The partitioning of the code in the Payroll example is just that, ... There are many reasons why such a separation might be beneficial. ...
    (comp.object)
  • Re: Critique of Robert C. Martins "Agile Principles, Patterns, and Practices"
    ... wrap the SQL. ... forget about the SQL and Schema while dealing with the business rules ... The partitioning of the code in the Payroll example is just that, ... such a separation might be beneficial. ...
    (comp.object)
  • Re: Use a variable number of fields
    ... I think business rules would ideally be enforced throughout the ... I would enforce this rule in front end form, ... Some business rules are too complex to be implemented as SQL ... Some business rules can be implemented as SQL constraints ...
    (microsoft.public.access.tablesdbdesign)