A: 

Hardly, anyone can tell you which design pattern is suitable for your problem. I would suggest you to, just study those design pattern which you think are suitable for you problem. you find more than one design thet can fix you problem. Just implement them, write code and then again study your reuqirement. Again go with other design pattern and implement that. Eventually you will end with correct design. This is the way you can learn the design pattern and difference between them, that will help you in future to choose the correct design. Design pattern are ready solution suggested by GOF, they do not solve any problem directly. They just give you right direction.

Reader
A: 

One thing that looks wrong is your multiple if statements inside your for loop, and unique variables to hold the scraped data. This means if your methods retrieve values for multiple pageContents, the variables will be written over and the previous value lost.

Is that what you want? If not, you should refactor your for loop and your if statements, maybe by just passing the entire list to the getName, getAddress, etc. methods, or some other way, but it's not entirely clear how your code is supposed to work. Depending on what the data looks like, the code could probably be optimized, by maybe sorting the list...

JRL
@JRL I didn't mention in the code that the values of the variables will store in the database at each loop so before the variables lost their values, the values are written to the database.
Yatendra Goel
I have edited my question now so it may be more clear to you and others.
Yatendra Goel
A: 

Do you think there is anything wrong or unwieldy about the current design?

I don't think it is clear yet to what design pattern this may be factored, if at all. One thing isn't clear for me, what exactly is the desired output of the scraping process?

That said, here are my 2 cents: The 1000 * 20 comparisons most likely don't mean anything performance wise. You could restructure the code so that the checks are made only once with polymorphic objects or something, but that will most likely be way overcomplicated. Something similar to the strategy pattern perhaps. I wouldn't do it yet though.

I would however make a very simple 'scraper' class, which contains exactly the same code as in your for-loop but the choices are set with booleans or something. Then have a seperate method create a scraper object from either the gui or xml file. From there you can refactor further if the need arises.

Lutger
A: 

For a very simple application as yours seems, choosing a classic design pattern for the overall application framework might be more of an academic exercise than anything else. Such a design pattern might turn out to over-complicate the program. In reality, the approach you have taken works well for small aplications. One improvement for readability would be to methodize the process within your for loop.

That said, from your example it seems that you are testing the state of your checkboxes from within the main method. I would expect this code to reside, instead, within a method like actionPerformed (inherited from the ActionListener interface), or some similar Observer that would react to Swing events. I would suggest a GUI design that provides a button to trigger the action, and your app would register as an ActionListener. This would allow for the user to select the checkboxes that apply to his query, and then trigger the action. Within the actionPerformed method you could move your trigger to begin the parsing of your page content. You will want to be wary of the threading constraints that Swing provides, and move your database calls to a worker thread. If you are not already familiar, take a look at SwingWorker.

akf