Re: Decouple SQL queries from class in OOP design



Well, it's not that you cannot put SQL in classes. Even if you put it
outside (in files, in a daabase), it's quite likely that things would
break if you change it in certain ways (in most ways) - so you pay in
additional complexity without gaining much - if anything at all.

What you want to do is to shields client classes from the
implementation details of querying. You do that by defining an
interface which exposes querying behaviour in a form which is
independent from SQL. Then you implement this interface in the most
efficient way - namely, classes that handle their own SQL.

These classes can in turn be defined so that certain parts are
configurable (say, the database schema, the name of the tables etc) but
the structure that is *fixed* at any point isn't. Beyond a certain
limit, attempting to configure everything becomes overdesign - since
you pay as much for changing configurations than for changing code, and
usually without all the checks and balances provided by the compiler
and (depending on opinion ;-) static type checks.

.



Relevant Pages

  • Re: Application, database and schema?
    ... > hardware interface for the monitoring. ... This subsystem understands how to talk to the ... > this case an RDB with a SQL interface. ...
    (comp.object)
  • RE: open a text file using sp_oamethod
    ... sp_OAGetProperty Fails on Properties From Inherited Interface ... Source: ODSOLE Extended Procedure ... When no OUTPUT parameter is supplied, ... Microsoft has confirmed this to be a problem in SQL Server 7.0. ...
    (microsoft.public.sqlserver.programming)
  • Re: code sharing for sql2k and sql-ce
    ... I think the idea of coding against an interface is perfect given what you're ... "ExecuteNonQuery", ... You should not have to put SQL in your ... > So it seams that I will have to use sql statement in source code, ...
    (microsoft.public.sqlserver.ce)
  • Re: Opinions on approach, please...
    ... Write the where clause manually, ... MOST interface, with the original COBOL ISAM access commented out above it. ... I can certainly do it with dynamic SQL and MOST can build a WHERE statement ... application is doing lengthy sequential processing, how often, in what ...
    (comp.lang.cobol)
  • Re: Putting data in SQL server ?
    ... web interface while keeping the MDB frontend. ... the data into SQL server. ... regarding such a conversion? ...
    (microsoft.public.access.tablesdbdesign)