Re: A question on database access classes - a little long, sorry



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?

.



Relevant Pages

  • Re: iptables udp and output
    ... > you might have to explicitly load. ... > for TABLE in filter mangle nat; ... where you had to specify what you wanted to block. ... > thx for the explanation ...
    (comp.os.linux.security)
  • Re: DAC Reconstruction Filter
    ... SNR is specified at 75dB for: ... So you need to specify your filter to pass what you want and attenuate what you don't want. ... filter with a 3db cutoff at fc/2. ...
    (comp.dsp)
  • Re: Creating Permanent Mof in Windows 2000
    ... should specify where the events originate in this case it should be ... __EventFilter and the consumer class must be in the same namespace. ... > The ActiveScriptEventConsumer is in Root\Default. ... The filter is not active" ...
    (microsoft.public.win32.programmer.wmi)
  • Re: Filter controls
    ... I simply want the user not to have to specify which control to search ... Find as you type - Filter forms with each keystroke ... If you are asking how you can apply the same filter value to multiple fields ...
    (microsoft.public.access.formscoding)
  • Re: who does when what report
    ... There is already one filter condition being applied. ... On the definition tab, change the filter to the one you just created. ... > booked for the date range that i specify. ... I want to restrict this report to display only ...
    (microsoft.public.project.pro_and_server)