Re: Decouple SQL queries from class in OOP design
- From: "Mikito Harakiri" <mikharakiri_nospaum@xxxxxxxxx>
- Date: 22 Nov 2005 11:50:39 -0800
Patrick May wrote:
> I don't understand the point of your question. Are you
> suggesting that there is no potential for reuse of business
> functionality across different applications?
Component reuse is a fiction rather than reality
http://jdj.sys-con.com/read/152251.htm
It is difficult to justify the need in complex component in a trivial
world of
"Fetch the data from the database, massage it, display it on the
screen"
> > > - Embedded SQL requires more than a simple SQL statement.
> > > The application must deal with database connections,
> > > transactions, cursors, etc. Encapsulating this overhead and
> > > allowing it to be reused across multiple applications reduces
> > > the complexity of each application and the opportunity for
> > > bugs to be introduced.
> >
> > If you have any difficulty opening database connection, or iterating
> > a cursor, you may think refreshing your programming skills. Those
> > are not the kind things that are worth abstracting.
I forgot transactions, that you mentioned. Are you aware that SQL
handles transactions as transparently as it possibly can? Are you
suggesting that you can raise application abstraction level to the
point when application programmer don't have to be aware of the
difference between optimistic and pessimistic locking?
> The application should focus on _why_ it needs particular
> functionality and _when_ to invoke that functionality. Mixing
> database access details and schema-specific logic in with application
> logic reduces maintainability. Further, duplicating that logic in
> multiple applications contributes further to maintenance problems and
> introduces more opportunities for bugs.
What maintainability? If I change the schema, does it affect the
connection? Nope. If I add a column to the table, the application would
still be happily iterate the cursor, and get all the required fields
from the record.
> > > - Encapsulating SQL in components or services that expose
> > > required functionality instead of the underlying database
> > > schema makes impact analysis much more straightforward and
> > > reliable. When SQL is embedded in applications across the
> > > enterprise, it becomes virtually impossible to determine the
> > > effect of any proposed change to the database schema.
> >
> > If the schema change is nontrivial (because just adding a column
> > wouldn't break anything), then you make backward compatible
> > views. Is this kind of obvious?
>
> And for the next change? And the next? Are you suggesting that
> adding an arbitrary number of new views with names like EMPLOYEE_V1,
> EMPLOYEE_V2, EMPLOYEE_AS_OF_20051122, etc. is better practice than
> encapsulating the business functionality required in one place? What
> about changes that are more complex than simple additions? Those
> views are going to start to affect performance.
You are constantly repeating the point about changing the schema, and
yet give no example of such a change. Once again, most schema changes
don't affect the application. Columns are never deleted from existing
tables. New columns and table addition won't affect any application.
The only significant change that could break the existing application
is a pretty serios schema reorganization.
The naming you use is completely wrong. I don't know how you name your
classes and methods, but it is possible to name the tables in a
meaningful way. If you have EMPLOYEE_V1, and EMPLOYEE_V2, then it is
very likely that they don't differ in a few extra columns which doesn't
justify introducing a new name at all.
.
- References:
- Decouple SQL queries from class in OOP design
- From: Hongyu
- Re: Decouple SQL queries from class in OOP design
- From: Robert C . Martin
- Re: Decouple SQL queries from class in OOP design
- From: Mikito Harakiri
- Re: Decouple SQL queries from class in OOP design
- From: Bruno Desthuilliers
- Re: Decouple SQL queries from class in OOP design
- From: Mikito Harakiri
- Re: Decouple SQL queries from class in OOP design
- From: Patrick May
- Re: Decouple SQL queries from class in OOP design
- From: Mikito Harakiri
- Re: Decouple SQL queries from class in OOP design
- From: Patrick May
- Decouple SQL queries from class in OOP design
- Prev by Date: Re: Decouple SQL queries from class in OOP design
- Next by Date: Re: Decouple SQL queries from class in OOP design
- Previous by thread: Re: Decouple SQL queries from class in OOP design
- Next by thread: Re: Decouple SQL queries from class in OOP design
- Index(es):
Relevant Pages
|