Attributes encapsulates publication data and the matching behavior used by a book catalogue. Moving these details out of Book and Catalogue prevents new attributes from leaking into constructors, searches, and conditionals. section 2.3.2
The design develops in stages:
- Start with shared title, author surname, and author first name fields; add year and Genre values for fiction. section 2.3.2
- Represent each book’s attributes as key–value pairs, using Key for names and a variant value for strings, integers, and enumeration types. section 2.3.4
- Let is_match compare only the target pairs, so omitted target attributes act as unconstrained search criteria. section 2.3.4
- Use enumerations such as Genre, Region, Kind, and Subject for limited value sets instead of error-prone strings. section 2.3.2 section 2.3.4
Partial attribute search
A target containing KIND = fiction, LAST = "KING", and GENRE = horror matches fiction books by King in the horror genre, regardless of title, first name, or year. Matching remains inside Attributes, while Catalogue only delegates to is_match. section 2.3.4
The architecture figure helps trace how Attributes separates changing publication data and matching behavior from Book and Catalogue. section 2.3.2
