4 ms·
The description of the solution sounds like a Factory to me. Is the Identity Map any different to a Factory approach?
by mise 15y ago
The description of the solution sounds like a Factory to me. Is the Identity Map any different to a Factory approach?
- deleted 15y ago[deleted]
- latch 15y agoYes, they are different. The Factory Pattern is a pretty basic creational pattern. An Identify Map is more specialized. It specifically exists to avoid having multiple instances of the same entity. An identity map doesn't create objects, but it does cache and short-circuit the creation. If you did: id = 1 userA = Factory.create(:user, id) userB = Factory.create(:user, id) You should reasonably expect userA and userB to be different instances. If you asked an Identity Map for the same thing, they'd be the same instance.
- jvega 15y agoSounds more like singleton pattern. The concept is interesting, but the implementation is very intrusive Every new release of "Backbone" they must be merge his changes