liveBook · Manning

Attributes

As explained in Object-Oriented Software Design in C++

A book-specific class that encapsulates publication attributes and matches them against search targets.

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

How Object-Oriented Software Design in C++ covers it

How deep it goes
Progresses from fixed fields and subclasses to map-based storage with variant values, but leaves ownership details explicit through raw pointers.
Examples
Demonstrates fiction and cookbook records, genre and region values, and partial searches for King novels or Chinese cookbooks.
What it assumes
Assumes introductory C++ classes, inheritance, enumerations, STL maps, and variants while teaching encapsulation through incremental refactoring.
What you can do after
Builds a flexible C++ attribute object that stores heterogeneous values and supports partial matching through Catalogue.
How it connects
Connects encapsulation, delegation, loose coupling, enumerations, maps, variants, inheritance, and the Open-Closed Principle.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Object-Oriented Software Design in C++. The section links point to the parts of the book it draws on.