Re: Decouple SQL queries from class in OOP design
- From: "frebe" <fredrik_bertilsson@xxxxxxxxxxx>
- Date: 10 Nov 2005 02:12:51 -0800
> 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.
Your application (and classes) will be bound to the local database
schema anyway. This mapping has to be done somewhere. Your classes "on
top" of the SQL statements will not survive any major schema changes
just because you separate the SQL strings.
> But I am not sure
> what the best way is to decouple them. The method that I am using right
> now is to create a hash to store all the SQL statements and prepare
> them in the main program, then I will pass this hash as a variable to
> all the classes that are going to use it.
This design will probably just cause you and your colleagues extra
work. When you add functions to your application you both have to edit
you classes AND edit the SQL statement list. When someone tries to read
and understand your application, he has to read both the classes and
the SQL statement list simultaneously to be able to understand what the
application actually do.
Fredrik Bertilsson
http://butler.sourceforge.net
.
- References:
- Decouple SQL queries from class in OOP design
- From: Hongyu
- 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
|