I'm looking for a pattern describing a certain situation. Maybe someone knows something and can give me a hint
Situation Object of type A, 1 : n association to objects of type B. Example: A Person and all his pets. The pet objects have an age data member. Now each person should have a data member for the average age of his pets. I don't want this information to be saved and loaded but to be computed during the loading process (all necessary information is already there, so it's kind of redundant, but I want the information in the person object).
Question So how can I do this in an object oriented way? Is there a pattern that describes this situation? My first idea was to have a class ComputedFieldsUpdater who takes a pet object and then computes all the field that have not been loaded. But I wonder if this is the right way or if there might be a more elegant solution?
Thanks for your thoughts.