Design and Implement an Object-Oriented Music Player in Go
You are tasked with designing and implementing a small, object-oriented music management and playback system in Go.
Requirements
Core Domain Types
The system must define and manage the following core domain types:
- Song
- Playlist
- Player
Playlist Features
The Playlist type must support:
- Adding and removing songs.
- Reordering or moving songs within the playlist.
- An optional deduplication toggle to prevent duplicate songs by a unique ID.
Merging Playlists
The system must allow merging two playlists. When merging:
- The relative order of songs from each source playlist must be preserved.
- A clear duplicate-handling policy must be defined and implemented (e.g., keep-first, keep-last, keep-both).
Player Controls and Behavior
The Player type must implement standard playback controls and behaviors:
- Play, pause, next, previous song.
- Shuffle functionality.
- Repeat modes (off, repeat one song, repeat all songs in the playlist).
Engineering Aspects
The design and implementation should demonstrate:
- Clear APIs and well-defined data structures.
- Discussion of time and space complexity for core operations.
- Consideration for concurrency to handle simultaneous edits and playback, designing for thread safety.
- Consideration for persistence, specifically how to save and load playlists.
- An outline of unit tests for core behaviors.
Assumptions
Assume a console-based player where actual audio playback is not required. "Playback" refers to managing the player's internal state and current song position.
AI interview prep
Core dilemma
Balancing efficient, thread-safe state management for dynamic playlist operations (add, remove, reorder, merge, shuffle) with clear API design and extensibility, especially under concurrent access.
3 tradeoffs and 3 stress tests locked
Interview prep
Unlock the interviewer X-Ray rubric, tradeoff matrix, stress tests, clarifying questions, and key concepts.
Design and Implement an Object-Oriented Music Player in Go
You are tasked with designing and implementing a small, object-oriented music management and playback system in Go.
Requirements
Core Domain Types
The system must define and manage the following core domain types:
- Song
- Playlist
- Player
Playlist Features
The Playlist type must support:
- Adding and removing songs.
- Reordering or moving songs within the playlist.
- An optional deduplication toggle to prevent duplicate songs by a unique ID.
Merging Playlists
The system must allow merging two playlists. When merging:
- The relative order of songs from each source playlist must be preserved.
- A clear duplicate-handling policy must be defined and implemented (e.g., keep-first, keep-last, keep-both).
Player Controls and Behavior
The Player type must implement standard playback controls and behaviors:
- Play, pause, next, previous song.
- Shuffle functionality.
- Repeat modes (off, repeat one song, repeat all songs in the playlist).
Engineering Aspects
The design and implementation should demonstrate:
- Clear APIs and well-defined data structures.
- Discussion of time and space complexity for core operations.
- Consideration for concurrency to handle simultaneous edits and playback, designing for thread safety.
- Consideration for persistence, specifically how to save and load playlists.
- An outline of unit tests for core behaviors.
Assumptions
Assume a console-based player where actual audio playback is not required. "Playback" refers to managing the player's internal state and current song position.