2
Contributors
3
Replies
26
Views
3 Years
Discussion Span
Last Post by Momerath
1

You should have a class for each type of report and a class for displaying each type of report. You then have a class (Report class) that takes an instance of the class for the report and the class for displaying the report.

Then you'd have a factory class that you pass the string into, and it returns an instance of the Report class with the specific instances of report type and display report.

Why do it this way? If you have to add a new report format or display method you can do so knowing it won't break all the other report formats and display methods. The only class that needs changing is the factory.

I can show you an example of what I mean, if you'd like.

Also, you are doing way too much in your code, you need to break it out into methods. Something like

public void Main() {
    DisplayMedium whereToDisplay = null;
    StorageMedium whereToStore = null;

    List<Reports> theReports = GetReportData(<file path, database, whatever>);

    whereToDisplay = new ConsoleDisplayMedium();
    DisplayReportData(whereToDisplay, theReports);

    whereToDisplay = new PrinterDisplayMedium();
    DisplayReportData(whereToDisplay, theReports);

    PrintSingleReport(whereToDispaly, theReports[3]);

    whereToStore = new DatabaseReportStorage();
    StoreReports(whereToStore, theReports);
}

Edited by Momerath

Votes + Comments
Also helpfull for me!
0

Is my current CSV parsing fine though? That's half my issue.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.