Although I have done a reasonable amount of coding I have very little training (self taught) so apologies if this is a stupid question.
I have written a basic Defect Management app which allows developers to create a release and assign defects to it. The release object has the usual id, name etc and an object called DefectCollection with is a collection of Defect objects. When I load a Release (using it's load method) it calls the PopulateFromRelease method of the DefectCollection. This all works.
However, I now have a ReleaseCollection object which I can populate from a method such as 'LoadAllReleases' which also works, the problem is that for every release I load it loads all the defects for that release into new objects and thus I end up with thousands of defect objects many of them repeated.
The solutions I have so far are:
1, Leave it as it is it works but is inefficient
2, Create a 'master' defectcollection, preload it with all the defects and reference them
3, Write an defect collection that loads defects as required and allows multiple release objects to reference them
4, Write the defectCollection as a lazy collection populated only when it is referenced
This is only 1 occurrence of the same issue I have so any guidance on best practice would be very much appreciated.
Thanks in advance