Collection Class's

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I noticed in a sample app source code that the app made use of a class for
example a user class and then had the user objects that got created stuffed
into a user collection. I was wondering why do they do this if the user
object that was created existed for the life of the object why u would need a
user collection? I would think u could just call the user object and get your
info from that just as easily then going the extra step to put the user
object into a user collection. What am I missing here?

What is the user collection giving me over just using the user objects that
I can create by themselves? I hope I am explaining this correctly.

Thanks,

JJ
 
It all comes down to what you need and what your encapsulation objectives
are. If your app only uses a max of 1 user object at a time, then I don't
see any benefit of going the extra steps to create a collection that will
hold that one user. Of course you should always consider the likelihood of
possible expansion of your application's capabilities... today only one
user - but in the future possibly manage multiple users simultaneously
(something more common in Windows/Desktop apps). If such likelihood exists,
then it may prove useful to create the collection in your first round of
development in order to make the expansion easier in the future. It's a
judgement call on your part.

-GH
 
You might use a user collection, for example, as the datasource of a
datagrid, datalist, etc.
 
What is the user collection giving me over just using the user objects
that
I can create by themselves? I hope I am explaining this correctly.

For that matter, why would you ever need a Collection at all? Come on, now.
You haven't described enough about the app you were looking at to answer the
question! Obviously, Collections are useful from time to time, and
obviously, sometimes when using a Collection, you put instances of classes
into the Collection. Forget that the class was called a "user." It is a
class. Call it foo. Now let's take a look at your question with the
different name:
I noticed in a sample app source code that the app made use of a class for
example a foo class and then had the foo objects that got created stuffed
into a foo collection. I was wondering why do they do this if the foo
object that was created existed for the life of the object why u would need a
foo collection? I would think u could just call the foo object and get your
info from that just as easily then going the extra step to put the foo
object into a foo collection. What am I missing here?
What is the foo collection giving me over just using the foo objects that
I can create by themselves? I hope I am explaining this correctly.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
 
Back
Top