Re: Decouple SQL queries from class in OOP design
- From: "Mikito Harakiri" <mikharakiri_nospaum@xxxxxxxxx>
- Date: 22 Nov 2005 10:46:53 -0800
Patrick May wrote:
> The reasons why the application
> should not embed SQL in this case include:
>
> - It couples the application to the database schema. Changes to
> the schema (due, for example, to requirements of completely
> different applications or database administrator decisions)
> could break the application.
Wrong. The database schema outlives the application. I just went to DMV
where the clerk was still using character based entry screen. Now tell
me, which of the following is likely to happen on the next step
1. DMV would throw away the database of all vehiles/drivers/ etc in
california and write a completely new application with new persistence
store. (Persistence is just implementation detail, you know).
2. They write GUI based application that will work with existing
database. Both applications would coexist at some point.
> - The "validate employee ID" functionality is likely to be used
> in more than one application. Encapsulating it as a reusable
> component or service reduces the complexity of each application
> and provides more consistency across the enterprise.
Aha. In case #2 of my new example tell me what components of the old
application do you think would be reusable for the new application.
> - 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.
> - 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?
.
- Follow-Ups:
- Re: Decouple SQL queries from class in OOP design
- From: Dmitry A. Kazakov
- Re: Decouple SQL queries from class in OOP design
- From: Patrick May
- Re: Decouple SQL queries from class in OOP design
- 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
- 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
|