DEV Community

Discussion on: Java - reduce redundant objects with Flyweight Design pattern

Collapse
 
tehmoros profile image
Piotr "MoroS" Mrożek • Edited

Nicely explained. :)

One thing though: when you take data deserialization into account (whether it's "JSON/XML/gRPC to object" or ORM), then only the enum-based solution truly works "out of the box". That of course is a basic scenario.

Luckily most solutions (JPA/Hibernate, Jackson, etc.) offer the possibility of implementing a custom deserializer (again, whether it's a data deserializer or a ORM converter), so with little effort you can implement other strategies as well.