Simple Design question
The task is to generate a chart generator -
I have two classes for the same -
1) ChartValuesGenerator - this class generates the values which is required to plot the graphs.
2) ChartGenerator- this class generates the charts which are required. To generate the chart it requires the values generated from the ChartValuesGenerator
I am not able to decide which is the best design -
If i have to have an interface to connect these two classes i am not decide on what methods need to be abstracted and that stuff.
Any suggestions would be appreciated.
[592 byte] By [
ssv45324a] at [2007-10-2 21:19:08]

The idea that comes to my mind would be to use the Builder or Factory pattern instead. You would have a ChartFactory or ChartBuilder that makes a Chart by retrieving the values from some persistence layer, analyzing those values, and determining which Chart to make from those values. The ChartFactory/Builder would be provided references to objects of the persistence layer abstracted by an interface, so that the persistence layer can be changed. The persistence layer could be as simple as a text file parser. The Chart would draw itself, know its own logic, and perhaps be given different views, abstracted by an interface, to draw itself on. This way you modularize and separate the logic of determining which chart to use, the persistence layer (the means of getting the values), the logic of the chart that was chosen and how it works, and the views that display the chart to the end-user.
So the necessary classes in this idea are:
class(es) for controller(s)
ChartFactory
class(es) for persistence layer
Chart
class(es) for view(s)