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?
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.
Last edited by NewUniverse; 02-06-2009 at 04:19 AM.
There is no fear in the true love!
Last Post: 10-15-2007, 09:20 AM
By Need2CSharp in forum Architecture and Design
Last Post: 07-28-2007, 09:50 AM
By hemanthjava in forum Java
Last Post: 11-14-2006, 11:57 PM
By stoughto in forum Java
Last Post: 06-11-2006, 10:56 AM
By Gwen Smith in forum vb.announcements
Last Post: 07-21-2003, 03:17 PM
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL