If you compare the Flyweight and Prototype patterns,
I understand that there is a difference.Looking at this much, I thought Flyweight would cost less overall than Prototype, and I could do it including what Prototype can do.
So I have a question.
I know that there is a difference between generative and structural patterns, but I am worried that both of them look the same.
Thank you for your cooperation.
Reference Site:
https://www.techscore.com/tech/DesignPattern/Prototype.html/
https://www.techscore.com/tech/DesignPattern/Flyweight.html/
As mentioned in the questionnaire, there are the following major differences:
Because the Flyweight pattern uses objects around, it is usually only available for immutable objects.
Prototype patterns, on the other hand, have no such restrictions.
For example, Linked , if you want each of the 100 snow crystals to have a different color (=Paper
has a color
field and you want to set a different value for each object), you cannot use the object around.
In other words, the Flyweight pattern is not applicable.
(Examples of Prototype patterns with the same link can certainly be realized with Flyweight patterns, so it's hard to tell the difference.)
© 2024 OneMinuteCode. All rights reserved.