Re: A question on database access classes - a little long, sorry
- From: "Mikito Harakiri" <mikharakiri_nospaum@xxxxxxxxx>
- Date: 16 May 2006 11:11:15 -0700
libei71@xxxxxxxxx wrote:
But when the query condition became complex, I realized I should
have an interpreter pattern (combine with composition pattern) to
specify the search condition. Then I added an abstract class
'Filter' and some classes such as 'FilterDirectorEqualsTo with
constructor paramters (directorId)', 'FilterAnd (filter a, filter
b)' extend this abstract class. Then I only had to specify filter and
then retrieve records:
Filter f1 = new FilterDirectorIdEqualsTo(10);
Filter f2 = new FilterApprovedBy("TeamLeader");
Filter f3 = new FilterAnd(f1,f2);
List l = Reports.getReportsInfo(f3);
Filter f4 = new FilterLeaderIdEqualsTo(22);
Filter f5 = new new FilterAnd(f4,f3); // f3 could be reused
l = Project.getProjectsInfo(f5);
// they are used to generate the search condition after the 'WHERE'
in sql,so //they are tightly bound with database details
This design looks rather stupid. What is the point of having the Filter
class (with a bunch of ugly methods)? Do you imply that the user of
this class would be able to construct ad-hock query via these methods
calls? Can't he construct a dynamic query by just concatenating strings?
.
- Follow-Ups:
- Re: A question on database access classes - a little long, sorry
- From: libei71@xxxxxxxxx
- Re: A question on database access classes - a little long, sorry
- References:
- A question on database access classes - a little long, sorry
- From: libei71@xxxxxxxxx
- A question on database access classes - a little long, sorry
- Prev by Date: Re: Tell, Don't Ask
- Next by Date: Re: Programming to an Interface
- Previous by thread: Re: A question on database access classes - a little long, sorry
- Next by thread: Re: A question on database access classes - a little long, sorry
- Index(es):
Relevant Pages
|
|