Example class diagram

For the class diagram, first let's imagine that we are trying to represent a drawing for a color blindness test similar to the following:

As we can see, it is composed of circles of different sizes and colors. Potentially, this can be an infinitely big picture and it can have any number of circles. To make things simple, let's just set a limitation where we can only have five different circle colors—red, green, blue, yellow, and magenta. Here is what our class diagram will look like in order to represent an image like the preceding one using the flyweight design pattern:

The actual flyweight design pattern is implemented ...

Get Scala Design Patterns - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.