Skip to content

Instantly share code, notes, and snippets.

@ambersariya
Last active January 8, 2025 11:59
Show Gist options
  • Save ambersariya/ad7cd76a6898f05cc7c1bbbc3d20dde2 to your computer and use it in GitHub Desktop.
Save ambersariya/ad7cd76a6898f05cc7c1bbbc3d20dde2 to your computer and use it in GitHub Desktop.
Kata - Music Streaming Service

Music Streaming Service

Scenario

Test-drive code that manages the catalog and subscriptions of a digital music streaming service. Customers can browse and search the catalog by title, artist, and genre. Record labels and independent artists submit their tracks to the platform, and the service maintains a catalog with details about each track, including the streaming rights and availability status.

Key Features

  1. Track Availability

    • Maintain a count of how many streams are available for promotional tracks or limited-time releases.
    • Ensure that users can only stream tracks that are available.
  2. Subscription Management

    • Customers must have an active subscription to stream tracks.
    • Use dependency injection to fake credit card payment processing, allowing the focus to remain on designing the streaming service.
  3. Reviews and Ratings

    • Customers can leave reviews for tracks they've listened to.
    • Reviews include a rating (1-10) and optional text feedback.

TDD Guidelines

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.

Class Design Principles

Design classes that:

  1. Tell, don’t ask

    • Encapsulate behavior and data within cohesive objects.
  2. Have one distinct responsibility

    • Follow the Single Responsibility Principle.
  3. Can be composed from the outside

    • Enable flexible usage and integration.
  4. Expose client-specific interfaces

    • Tailor interfaces to specific client needs.
  5. Use contract tests for shared abstractions

    • Ensure reliable and reusable abstractions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment