Correct patterns. Factories
How can i implement this? or perhaps it is correct.
My case is the following one:
-I磛e got an object called "series" that represents a sequence of objects. For instance: BrushYellowSerie(set of yllow brushes), BrushRedSerie.
- I磛e got an object called "reports" that represents reports about the series. There are different kind of reports. A report can hace one serie, or two or free series or other objects regarding a external variable(called experienceType).
- I have thougth in creating a ReportManagerFactory. That allows me to choose the ReportManager depending the experience.
- There would be different kinds of ReportManager, one for report. For example ReportY, ReportAManager, ReportM.
- Each ReportManager must implement a function called "getAllReports". That will get all reports from a Experience. That is, if i 磛e got experience 7 that is of type 9 I磛e got 7 ReportJ.
- "ReportAManager.getAllReports" will return an ArrayLIst of "reports".
The problem is: I磛e got thought in creating a class called "Report" with two attributes: Id and String. Later I would like to have a descendant class for each reportType (that is ReportA, ReportB, ReportC).
ReportA is the same that a Serie, and ReportAManager.getAllReports will return an ArrayList of ReportA. I 磛e got thought in calling directly a function that I磛e got that returns all the series. But this function return series
that is not a Report. Ive got thought that ReportA descend from Report and Serie. How can i pass the "array of Series" to an "array of ReportA". How can i do that?
> How can i implement this? or perhaps it is correct.
>
> My case is the following one:
> -I磛e got an object called "series" that
> represents a sequence of objects. For instance:
> BrushYellowSerie(set of yllow brushes),
> BrushRedSerie.
OK. Why? The color of the brush would seem to be merely an atribute of the brush. Do yellow brushes have a different behavior than red brushes?
> - I磛e got an object called "reports" that
> represents reports about the series. There are
> different kind of reports. A report can hace one
> serie, or two or free series or other objects
> regarding a external variable(called
> experienceType).
>
> - I have thougth in creating a ReportManagerFactory.
> That allows me to choose the ReportManager depending
> the experience.
> - There would be different kinds of ReportManager,
> one for report. For example ReportY, ReportAManager,
> ReportM.
> - Each ReportManager must implement a function
> called "getAllReports". That will get all reports
> from a Experience. That is, if i 磛e got experience
> 7 that is of type 9 I磛e got 7 ReportJ.
> - "ReportAManager.getAllReports" will return an
> ArrayLIst of "reports".
> he problem is: I磛e got thought in creating a class
> called "Report" with two attributes: Id and String.
> Later I would like to have a descendant class for
> each reportType (that is ReportA, ReportB, ReportC).
Why? If you don't need to create new types, you are usually better off not doing so. You can create new implementation classes but creating a bazillion global types in the system is definitely not good OO design.
> ReportA is the same that a Serie, and
> ReportAManager.getAllReports will return an ArrayList
> of ReportA. I 磛e got thought in calling directly a
> function that I磛e got that returns all the series.
> But this function return series
> that is not a Report. Ive got thought that ReportA
> descend from Report and Serie. How can i pass the
> "array of Series" to an "array of ReportA". How can i
> do that?
What problem are you trying to solve? Start there.