3 ms·
> This seems not much more than trying to standardize a global registry lookup for your models. Why not just make your collection globally accessible, and refer
by prateekdayal 15y ago
> This seems not much more than trying to standardize a global registry lookup for your models. Why not just make your collection globally accessible, and reference the fetched model with
Because the collection could be inside another object. Also there would be other places in the app where ticket models are being initialized. By defining/having to refer to global variables, you are just writing code that is harder to maintain.
The identity map approach is more like Rails where in a single request, the same SQL does not hit the db again and just returns the pre-fetched results. You don't have to think about where else you are fetching the same records ever.
- prateekdayal 15y agoAlso a ticket could be present in two different collections fetched from different urls. For example, the same ticket could be in /tickets/all_tickets and /tickets/my_tickets. The book keeping just keeps getting harder as your app grows