I have always been told that I should only get the data I need for each web
page, so my quandary is set against that backgound.
Let's say I have a User class with 10 properties. I have a private method
that populates all of these properties with values from the database.
However, I may only need to display two of the properties on a web page
(name and last login time, for example). Coming from a pure ADO/ADO.NET
background, where I would only retrieve these two values and plug them into
their place on the page, this seems a bit wasteful to me. I can see that in
the event I might need to display more properties, I only need to make one
small change in the ASP.NET page, as the values are already available, but
should I really be thinking about creating other private methods that
instantiate a User object but only populate some of the properties?
Is this part of the trade off I should accept when using an OOP approach, or
should I be looking at it differently?
page, so my quandary is set against that backgound.
Let's say I have a User class with 10 properties. I have a private method
that populates all of these properties with values from the database.
However, I may only need to display two of the properties on a web page
(name and last login time, for example). Coming from a pure ADO/ADO.NET
background, where I would only retrieve these two values and plug them into
their place on the page, this seems a bit wasteful to me. I can see that in
the event I might need to display more properties, I only need to make one
small change in the ASP.NET page, as the values are already available, but
should I really be thinking about creating other private methods that
instantiate a User object but only populate some of the properties?
Is this part of the trade off I should accept when using an OOP approach, or
should I be looking at it differently?
Comment