Strategy Pattern?


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 2 of 2

Thread: Strategy Pattern?

  1. #1
    Join Date
    Mar 2005
    Posts
    105

    Strategy Pattern?

    Hi All,

    I have recently taken ownership of a reporting application that is very poorly designed and I'd like to apply a pattern to fix it.

    All the reports have a input (which queries the database), a summary level screen that uses a datagrid, and a detail level screen which again uses a datagrid. With the Strategy Pattern in mind, I'm thinking of creating a base Report class and letting all the various report types inherit from it. Since the inputs vary depending on what report you're running, I'm thinking of making this the behavior interface. The input section consists of dates and other reporting filtering options.

    Does the Strategy Pattern sound okay for this or am I missing something?

  2. #2
    Join Date
    Mar 2004
    Posts
    78
    Hi,

    Using the strategy pattern you can do something like this(I hope I understood the problem):
    1. Obviously you have a logic executed on all types of reports - the one that loads a report, invokes it(build results or something), present the results(supply the data required by the different views you have) - well it sounds like a controller.
    The controller does one and the same thing with all reports by managing their life-cycle. It can do this by making all reports implement a specific life-cycle interface(invoke, buildResults and so forth)
    2. The controller loads a report depending on the user selection(type of report and the data it needs) using a Factory object that hides how the different reports are created.
    The factory will produce report of the correct type using a specific method or using a specific object that knows how to produce the desired report if it is too complicated.
    3. The concrete implementations of report interface will differ by their input data and what they do with it. Because of the is-a relationship inheritance is a choice but I think it is better if you use composition.

    So I guess in order to solve you problem you engage the factory and strategy patterns(controller is who uses the different types report building logic).

    I hope that I understood the problem properly and that my idea helps.

    Bye
    Last edited by NewUniverse; 02-06-2009 at 03:19 AM.
    There is no fear in the true love!

Similar Threads

  1. Replies: 0
    Last Post: 10-15-2007, 08:20 AM
  2. Correct Design Pattern for Order Form
    By Need2CSharp in forum Architecture and Design
    Replies: 1
    Last Post: 07-28-2007, 08:50 AM
  3. Java Singleton Pattern Tutorial
    By hemanthjava in forum Java
    Replies: 2
    Last Post: 11-14-2006, 10:57 PM
  4. how to list resources in a package?
    By stoughto in forum Java
    Replies: 2
    Last Post: 06-11-2006, 09:56 AM
  5. Replies: 0
    Last Post: 07-21-2003, 02:17 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center