This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Say I've got two tables with matching Java Beans. We'll call them Order and OrderItem. The Order bean contains a Collection which holds all OrderItem beans of that order which is modeled in the DB as a One to Many. My question is should not the developer know exactly when they will need only the Order bean and when they will need both the Order and OrderBean collection populated? Loaded the Order bean with the Collection populated is an added cost and if I do not yet need it, why do it? The reason I ask is we are currently reevaluating how our DB access should be handled. One of the leading candidates is a tool that determines when to load the children for you. So, if I only load the Order, the OrderItem Collection will not be populated until I try to access it (I can also force an init of the Collection which will do this). Since this 'hides' when the data is loaded and there is no longer a need for an explicit load of this data, I wonder if this is good practice. If I load an Order in a Servlet and forward to a JSP which shows the OrderItem collection, this method of loading the children will do it for us at the JSP level, which breaks the strict MVC (JSP being the View) model. Any opinions and comments are requested.