Many objects that we create have attributes that imply other objects. For example, the .owner attribute of a repository returns a String representation of the owner's name, but it could more usefully return a User object representing the same user. It would be expensive to handle this naively, so we ideally want an architecture that will automatically instantiate such objects on demand. If the caller just wants the owner's name,return a string; if he wants the owner's e-mail address, create a User object and call the .email method.
We currently handle one of these cases by accepting a parameter specifying whether the caller wants objects or strings for User objects, but given the prevalence of such cases a general, "do the right thing" approach would be optimal.
Many objects that we create have attributes that imply other objects. For example, the .owner attribute of a repository returns a String representation of the owner's name, but it could more usefully return a User object representing the same user. It would be expensive to handle this naively, so we ideally want an architecture that will automatically instantiate such objects on demand. If the caller just wants the owner's name,return a string; if he wants the owner's e-mail address, create a User object and call the .email method.
We currently handle one of these cases by accepting a parameter specifying whether the caller wants objects or strings for User objects, but given the prevalence of such cases a general, "do the right thing" approach would be optimal.