?
Solved

defining multiple classes for categorizing objects(!?)

Posted on 2003-03-31
2
Medium Priority
?
172 Views
Last Modified: 2010-04-01
Hi all,

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!

Thanks.

0
Comment
Question by:crazyklink
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 2

Accepted Solution

by:
skyDaemon earned 150 total points
ID: 8242403
I would think it really comes down to what you're going to do with these lists in the end.  Basically, if you expect to perform most of your operations by classification type (ie, do x() to all "java" types) then I'd think you'd be better off with separate lists.  If you expect to perform most of your operations on everything regardless of type then try one big list.  Personnally, even in that situation I'd consider separate lists.  It's just nicer when you don't have to special case every operation or search you do on a generic list.  That's assuming of course that things like the order of the projects don't matter, and they don't HAVE to be sequential etc etc.  Unless you lose something I'd go with the separate lists.

Alternatively, you could do an inheritance model where each type has a different derived class.  This only makes sense if you need generic processing, or have a lot of common functions.  If so, the one big list of different inherited objects may make sense.  All the runtime type info stuff is fairly slow, but not so bad that you couldn't use it.  I work with a system that was designed with a lot of flexibility and expandability in mind.  We use an inherited class hierarchy for our transaction base and push it all through a largely generic central engine.  It's done well for us, but we put a lot of time into the initial design of our class hierarchy to allow us to expand later on.

The choice mainly comes down to what benefits you want in your program.  For speed alone, separate lists will likely do better for you.  For future flexibility and generic processing, the inheritance model.
0
 

Author Comment

by:crazyklink
ID: 8330112
Thanks...

Sorry for the delayed feedback! We working with the multiple lists - I just needed somebody to confirm the fact that I wasn't crazy by suggesting it!! ;o)
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question