[Tutor] Some advice on classes needed ?

Alan Gauld alan.gauld at blueyonder.co.uk
Sat May 15 07:50:53 EDT 2004

> If I design a class for one set of data, how do I generate all the
> instances of classes without 250 generate instances.
> data1=datastruct()
> data2=datastruct()
> ...
> data250=datastruct()
> What I am asking is, Is it possible to use a for loop ? ie dynamicly
> generate an instance name to then call ?

You don't need an instance name, you can store them ina list
There is a section at the end of my web tutor topic on OOP that shows
how to do this.

One thing to consider however is your design, remember that objects
own their own dsata arnd are responsible for processing it, so think
carefully about how that concept might change the basic way your
program functions. Are you going to pass a set of files to each
object to extract its own data? Or are you going to going to pass
each file in turn to each of the objects? Or are you going to
extract the data in bulk and then pass it to the object (so how do
you know what data each object needs if the object manages its own

Without knowing more about the details its impossible to say which
mechanism will work best. But large volume data cruunching can be
extremely inefficient if you get the approach wrong.

Alan G.

More information about the Tutor mailing list