Discovery Architecture 

Whimzical! 

Twitter: Doing & Did 

    geeDavid's PC? 

    Search 

    My Flickr Stuff 

      www.flickr.com

    This week I have continued with a search related project and was tossing a lot of ideas through my head on how best to design a solution that simplifies interaction with a search engine for a JSP developer.  In my ruminations I considered a Factory pattern, among others, but realized late last week that in my case a Builder pattern fits beautifully.  

    My queries are not SQL queries but may contain search strings, filters, sorting preferences, etc. The number of plausible scenarios is lengthy and the parameters needed to create a 'right sized' query object are numerous (from a minimum of four to as many as a dozen.)  In addition the combination of parameters, as viewed from the perspective of the scenarios, is significant and some kind of test needs to be applied in order to ensure that the query is valid before it is shipped off to a search engine.

    Hmmm, a complex object that is created with 'exactly' the right parameters and no more? What we need here is a builder.  Thanks to "Effective Java" by Joshua Bloch I have a workable solution.  

    Here are some points to consider:

    • The builder encapsulates object creation

    • Objects can be created through a series of steps (I think of this as a buffet - choose a salad, an entree, and a side)

    • The client is unconcerned with how I represent this object internally

    • It is an extraordinarily flexible (object oriented) solution.

    • However, (yep, there is a downside to anything) the client will need more 'domain' knowledge than if a Factory pattern is used and there may be some overhead associated with the 'director' and 'builder' aspect of the pattern.


    This is a 'sweet' solution that appeals to me almost as much as a weekend in the mountains. . . almost.

    Comments (0)
    David Wilkerson September 16th, 2009 01:33:38 PM

     Comments
    No Comments Found
     Add a Comment
    Subject:
       
    Name:
    E-mail:
    Web Site:
     
    Comment:  (No HTML - Links will be converted if prefixed http://)
     
    Remember Me?