Newbie question on collections

A

aaj

Hi all

this is the first dip of my toe in to and OO type language and I'm having a
little problem

I have 4 classes

1) an infterface class with a button on it (frmmain). The button
instantiates the following..
2) a control object nameCTL
3) an entity object called nameCLS
4) a collection object called nameCOLL holding multiple nameCLS

I am having problems with the lifetime of the collection class.

Single items are collected in a text box and added and retrieved to the
collection via nameCLS, using nameCTL to manage whats going on.

All the time the form is live, I want to hold the data within the
collection.

What I would like to know is when to instantiate the collection class i.e.
should I make it into an object when the form opens, and then add to it each
time a new user is added via the contol class. If so, how does the control
class (nameCTL) access the collection class (nameCOLL) that was instantiated
within the form (interface) class.

Or should the control class create the collection as a singletom. This is
great in that the collection is only created once, but as far as I can see,
each time the contol object ends, the collection class will be destroyed!!


I hope the above makes sense.

Please help, I'm going around in circles tyying to solve a problem that
should be so simple!!!

thanks in advance

Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top