2 ms·
Yes, they are different. The Factory Pattern is a pretty basic creational pattern. An Identify Map is more specialized. It specifically exists to avoid having m
by latch 15y ago
Yes, 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.