Understanding the Traits Component
Note
TODO: an actual tutorial, for now the main points are listed.
Types are often viral because interactions between classes happen through the types known to those classes, e.g., for an object of type
T
to interact with an object of typeU
,T
must be able to understand the typesU
uses to access state and vice versa.With many Chemist objects actually consisting of a number of different classes, we need to synchronize types across those objects.
Also used for the template meta-programming to ensure const-ness is correct.
Traits allows a single source of truth for types associated a class.