This is something I've tried to solve a number of different ways, wanted
people's opinion on how they solve it.
I have a class, say users, which has a bunch of properties/methods. Problem
is I want to make available only a subset of this information, say I want to
have a list of "online users" which only makes use of the username and id.
Problem is, I don't want to have to load the entire object. In a sense, I
want to create a view of the object with only certain properties exposed. I
don't want to use lazy loading. I don't want to reuse my user class as is
and only partially load it, because that would result in weird behaviour
(ie, the "FullName" property is exposed, but doesn't work).
One of the ways I've handled this is to use a quasi-proxy. Something like
UserView which is composed of a User object. In this case the User object
is only partially loaded (via some specific internal calls to dal). That
isn't a problem because that's hidden from the consumer. The UserView class
doesn't expose the property of the User class which won't be loaded, so
there's no confusion.
I've also done the inverse. Where my User class would be composed of the
UserView class. This to me is a more tranditional form of composition, but
it doesn't fit as well with this "view" way that I'm thinking.
Not too crazy about the word view for XXXView either :)
Anyways, anyone doing something better than that? :)
karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!