DEV Community

loading...

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

Collapse
ramanbedi1989 profile image
Raman Bedi

Hi Abhinav,
Thanks for the article, it helps to understand Flyweight DP with examples.
Please clarify one doubt that I have. For the ProductCache, don’t we need to add the newly instantiated “product” to the “productMap” before returning it so that the following lookups always return the cached instance?

Collapse
abh1navv profile image
Abhinav Pandey Author

Correct. Thanks for the correction.