Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question: Where and when should I use the collection (Lists, Stack, etc . . .)

 
Preston Thornton
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good morning from Detroit, Michigan:

I have a question about using the java collection (Stack, Lists, etc.). I have taken the basic and intermediate programming classes in C++ and Java. I am about to start a class in C++ focus in data structures. Now I have already read up, or have had some exposure to the to this topic before in java, but I still have not truly seen how you use Stack, Lists, and such is used in the development of an out-the-self application in a situation such as memory management of a accounting package, or video game. So, where do you use them in the real world.

Preston.
 
Campbell Ritchie
Sheriff
Pie
Posts: 50196
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In accounting, you might have Account objects, or Expense objects, which might go in a List. [A lot of accounts packages actually link to a database, however.]
 
fred rosenberger
lowercase baba
Bartender
Posts: 12196
35
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We use queues all the time for message processing. the sending applications can all write to the queue, and there messages get interleaved (i.e. message 1 is from application 'a', message 2 is from 'b', message 3 from 'a', 4 from 'c', etc).

But all the messages from application 'a' have to be processed in order. the program that reads and process the messages pulls them off in order.

using a queue allows many applications to write at whatever rate they want to the queue, and the processing application to read them off at whatever rate it wants to.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
These data structures are used *everywhere*, literally (although you didn't mention maps, which are also ubiquitous). Google maps: a route is a list of waypoints. Games: there's a list of sprites (and a prioritized queue of events). Shopping *list*. *List* of account transactions. *List* of memory references. *Maps* of file system entries.

*List* of things that use collections.
 
Preston Thornton
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay! Thanks for the focus adjustment on this topic. I will make sure that I pay full attention in regards to these topics in the Data Structure course.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A structures class (or just the knowledge, barring a class) is critical, and has remained one of the most important classes I took some 25 years ago.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12196
35
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
also, remember that learning should be cyclical. your prof. will say "this is important, but you won't necessarily understand why yet". It took me a few years before I really understood why/how using interfaces was a good idea. I did it, because they told me to, but i wasn't sure why. As i learned more about other things, i gradually realized why they are so powerful.

it's the same with data structures. You may not see an immediate need for one, and it may seem odd that anybody would ever come up with such a thing. Just remember that someone, somewhere needed EXACTLY THAT, and other soon realized it would solve their problems too. Almost all of them will seem silly, until you need EXACTLY THAT.

some of it you just have to take on faith.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic