Flyweight or Type Object?
Both the Flyweight and Type Object patterns deal with performance and optimization in similar ways, and they’re often taught all mashed together, which makes it difficult to understand the intent behind each one and the different solutions they offer.
With the Type Object pattern, the intent is to create new complex classes without using big inheritance hierarchies. This pattern is also about data rather than behavior (as Type Objects don’t typically act on extrinsic state), but you’ll see a fair bit of memory optimization as a side bonus. You also don’t see factories come into play with the Type Object because they are structured to privately create and return new instances of themselves, so there’s no additional need for this abstraction layer (which isn’t to say you can’t add it). Again, this is where the line gets murky between these two patterns, as they can be combined and still function, but the...