Your Ticket 🎫
DataCorp's ReportService exports sales reports in three formats:
PDF, CSV, and HTML. The export logic lives inside one method
with a growing if/else chain — adding a new format means editing
the same class every single time.
The QA team can't write isolated format tests because the logic
is fused to the service. The senior dev says it's "unmaintainable."
Your mission:
Refactor ReportService using the Strategy Pattern:
1. Define an IReportFormatter interface with a
string Format(ReportData data) method
2. Create PdfFormatter, CsvFormatter, and HtmlFormatter
— each encapsulating its own formatting logic
3. ReportService must accept an IReportFormatter via its
constructor and delegate all formatting to it
4. No format-specific branching should remain in ReportService
You'll be scored on *structure*, not runtime behavior.