Practice ยท 3 of 3
Keep the Index Honest
Extend the repository idea: an indexed store where every write
maintains a secondary index. Implement in Solution:
- record Book(String isbn, String genre)
- static class IndexedStore with save(Book b) (upsert),
List<Book> byGenre(String genre) (insertion order), int size(),
and remove(String isbn) (boolean).
The index is the contract: byGenre must NEVER return a book that was
updated to another genre, re-saved, or removed. Upserting must move the
book between index buckets โ the exact bug from the lesson.
Difficulty: intermediate
Press Submit to check your solution.
Back to lesson: Practice: Persistence Lab