I just got confused about this approach. Pls offers me which is better. I will create several reports. SalesReport, ProfitReport, etc.
Approach - 1:
class Report
{
ReportType type;
}
Subclass ReportType as SalesType, ProfitType and assign it to instance reports
SalesReport:
Report sales = new Report();
sales.type = new SalesType();
ProfitReport:
Report profit = new Report();
profit.type = new ProfitType();
Approach 2:
class Report
{
}
class SalesReport : Report
{
SalesType type;
}
class ProfitReport : Report
{
ProfitType type;
}
Which approach is best? and better design? Many thanks.
Each report will have different criteria, different output options, such as email, print, etc.
class Report
{
ReportType type;
Criteria criteria;
Output output;
}
These classes are used as Entity classes. For example, from the browser / client we get xml <Report><Type>Sales</Type><Criteria>...</Criteria></Report>. Based on XML, I need to generate Report classes and pass it for processing. Based on the type of report it will be executed.
source
share