Types as Objects

Problem

Although representing domain types as classes is usually what we want to do, this can lead to multiple representations of the same entity when the entity may have multiple types. 

Solution

If the type of the object is descriptive rather than behavioral, then we can represent types as objects rather than classes. Here's the template:

Example

In an movie streaming application like NetFlix or an online movie database like IMDb, we might consider representing genres and ratings (G, PG, etc.) as classes:

This leads to an explosion in the number of classes. Adding a new genre will be a nightmare.

Since genre and rating don't affect the behavior of a film, we can instead represent types of films as objects: