Test-drive code that compares prices on smart TVs from three different sources, each with modern or legacy data access methods. The service will allow users to specify the make and model of a TV and recommend the retailer(s) offering the best price.
-
Screen Bargains
- An online retailer providing a RESTful web API.
-
Acme Tech
- A retail chain offering an outdated system with a SOAP-based web service.
-
TechSaver
- A mail-order company that uploads a weekly price list as a JSON file to a cloud storage bucket.
-
Price Comparison
- Allow users to input the make and model of a TV.
- Compare prices from the three sources and recommend the retailer(s) with the lowest price.
- If multiple retailers offer the same lowest price, list all of them.
-
User Interest Tracking
- Trigger a message to the ad targeting engine whenever a user searches for a TV.
- The message should include the make and model of the TV being searched.
Apply the following principles to ensure high-quality code:
- Working: Fully functional and passes all tests.
- Easy to Understand: Readable and maintainable for others.
- Minimally Duplicated: Avoid redundant code.
- As Simple as Possible: No unnecessary complexity.
Design classes that:
-
Tell, don’t ask
- Encapsulate behavior and data within cohesive objects.
-
Have one distinct responsibility
- Follow the Single Responsibility Principle.
-
Can be composed from the outside
- Enable flexible usage and integration.
-
Expose client-specific interfaces
- Tailor interfaces to specific client needs.
-
Use contract tests for shared abstractions
- Ensure reliable and reusable abstractions.
This version updates the scenario to reflect contemporary data access methods (e.g., REST, SOAP, JSON) and replaces outdated protocols like TCP/IP and Excel spreadsheets. The ad targeting engine integration reflects modern practices in personalized marketing.