defining multiple classes for categorizing objects(!?)
Posted on 2003-03-31
Ok I've been having a debate with team mate of mine about searching linked lists. The idea is we wish to implement a linked list that stores pointers to specific objects in another ADT. However each of these objects will have a certain distinguishing feature and they will be randomly stored in the list.
Lets say - a user enters in a project name and its classification is C++ - the pointer to this new object is stored in the list and points back to the projectClass which contains the attributes.
Now somebody comes along and enters another project name but this time its classification is Java...and the process repeats for lets say 100 more objects being stored in the ADT and pointed to by the list.
Now would it be more beneficial from a speed point of view when searching and displaying that the program contains just one linked list and is searched sequentially per code classification (eg - return all project names using searchkey "Java") or should we create two seperate linked lists (one for each classification) and send the objects to their respective classes so we'd have a javaProgram class and a CppClass where all Java Project names are store and all Cpp project names are stored resp.
Overall we'd expect to have maybe 5 seperate classifications of objects - so the user can search for all project names written in C, Perl, Python...whatever...
From a SE point of view would implementing seperate linked lists and seperate classes for each classification (but using the same linked list search, delete, add functions of course) make sense - is it be better to go directly to a linked list where you know all its pointers are to "java" project names and so search returns will be a lot quicker? (Although this will mean extra code!)
I hope this question makes sense - I need a whiteboard!!
Other suggestions to implement this sort of storage system are more than welcome of course!