Domain Searching Using Visitors
Subject:   Dynamic criterions
Date:   2005-06-07 12:03:03
From:   Paul_Mukherjee
Response to: Dynamic criterions

Selecting criteria dynamically is relatively straightforward; the standard pattern is by default to select a standard set of criteria and then use an advanced options dialog to specify any other set. Whatever the mode of selection, this is the means by which the search criteria objects described in the article are created. (As an aside you can use the GoF composite pattern to create complex families of criteria; using visitors this is easy!)

Choosing the columns to display in the result is more interesting; a naive approach would simply fetch a standard superset of columns and discard those not needed. However discarding information fetched from the database without using it always offends my sensibilities so I would create a ResultSpecification class that represents the columns to be presented. This would then be used by the visitor to define which columns to fetch from the database.