Object comparison in "Flyweight Pattern"

Asked

Viewed 36 times

3

I was reading that question, and I was left in doubt as to how the comparison is made between the objects, thus determining which object would be equal to the other, and which would be a new object.

Using the example of the same question quoted, about the game "Age of Empires", where there were thousands of type X warriors, and others Y with the same pattern of "properties", but only changed colors, or even the same warriors X, who were of the enemy, some questions arise, among them:

  • A new object is created before comparison or if it is compared only properties when creating, with some other already created?
  • This comparative is made of the whole object, with each property of it?
  • Assuming we have N equal warrior objects, but the living/dead property will be altered, so what? How would I treat a single object with different properties?
  • How is sorting done for comparison? There are criteria (type one index)?
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.