Suppose I have a CatHerder and he has Cats, when I getCatHerderByID(String id) should I load in the CatHerder and set an arrayList of cats or an arrayList of catIDs?
Suppose I have a CatHerder and he has Cats, when I getCatHerderByID(String id) should
Share
getCatHerderByID()should be a method which returns an object of typeCatHerder, which can have a propertycatsOwnedwhich will contain a list of IDs, populated by the constructor. In addition, you can have a method on theCatHerderobject calledgetCats()which returns an array ofCatconsisting of the IDs in theCatHerderobject. You shouldn’t load unnecessary information just because it has a relationship with the information you actually want — in many cases, everything will have a relationship with the data you actually want.