Design and Implement a Playlist Management Domain
Model an ordered playlist with stable entry identity, safe mutation contracts, and a bounded move implementation.
Design and implement the object-oriented domain for a Spotify-style playlist. For this exercise, assume tracks have immutable TrackId and metadata, while each insertion creates a distinct PlaylistEntryId so the same track may appear more than once.
A playlist has one owner, an ordered list of entries, and a monotonically increasing version. Support addTrack, removeEntry, moveEntry, and an immutable ordered read. Mutations validate all inputs before changing state, advance the version exactly once on success, and leave state unchanged on failure.
Moving an entry to its current index returns an explicit NoChange non-mutation and keeps the version unchanged. Return explicit outcomes for unknown TrackId, unknown PlaylistEntryId, invalid index, and stale expected version. Implement the bounded moveEntry behavior. Built-in collections are allowed.
Playback, recommendations, audio streaming, collaborative authorization, persistence technology, folders, sharing, and offline synchronization are outside the base scope; collaborative mutation is a follow-up.