I'm developing an ASP.NET application, for the first time from the ground up. I've been doing web development for 4 years, but our shop is classic ASP based with a SQL backed. We've begun migrating to ASP.NET but we're not really using it to it's fullest because we're still doing the backend using SQL which just sends datatable to the presentation layer for rendering, meaning we're not using the OOP approach and propery 3-Tier design.
So now that I am going down this road, I have a question. Suppose I have two business objects that are related, e.g., a Customer and a Shipping Address. The customer has properties such as Name, Race, Gender, Age and the Shipping Address would have your commen properties such as Street Address, City, State, Zip, Country.
Now then, the Customer object also has a property called ShippingAddress which is obviously enough, a ShippingAddress object. When I instantiate my Customer Object, I am also instantiating a new instance of ShippingAddress and supplying all of it's field. This seems straight forward enough.
But now my dilema is this - suppose I have a shipping summary page that a list of every customer who has been shipped an order that day, but it's only display their last name and street address (no city, state or zip) and suppose this report has several hundred people on it. Because I do not need the extra overhead of the customers Age or Race and I also do not need the overhead of their Shipping Address' City, State, Zip - how do I go about supply this report with the correct objects?
Do I instantiate the objects as-is and do not supply those properties with data?
Do I instantiate the objects as-is supplying all day, incurring the overhead, but not rendering the data on the report?
Do I create a new object(s), that has only the data this report needs and instantiate those instead?
I have no formal training in OOP, and most peopel tell me there is no best practice for this kind of thing, but I'd have to imagine there are people who have ran into this before and I'd like to know what some of your solutions have been.
Thanks!
Bookmarks