Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

an infinite array

Status
Not open for further replies.

A1METALHEAD

Programmer
May 21, 2004
76
US
ok, here is my situation, i need a database that contains titles to books, and each book has one or more assignments. each assignment has a end date, start date, name, description. also, the books have an optional array of lessons, each with a tital and a description, number of pages. i have already done evrything, exept for making an array. how do i make an array of abjects of infinite size that i can acsess an index with a string?

thanks,
~metalhead
 
Umm, you wouldn't.

Buy a copy of Martin Fowler's Patterns of Enterprise Application Architecture. In it, he goes over the Data Access Object (DAO) pattern.

The basic idea is that you have objects which represent your business entities, called DTO objects. These are loaded via corresponding DAO objects, which know how to do the database work for the DTO (your basic CRUD operations).

The idea is that you would show the user a list of books, let them select a book. Then show them a list of assignments for that book and allow them to select one. If the book has any lessons, then you'd show them a list of lessons and allow them to select one.

These operations can be broken down into a couple of basic operations:

1) Get a list of something.
2) Get a single instance of that something for viewing.
3) Edit the "something" and save it back (an Update operation).
4) Create a new "something" and save it back.

If you think the list of items will get large, you can design your DAO to bring back the rows from the database in pages, much like you see Amazon do it: "Now viewing items 50 - 100 of 20,000"

This way you reduce the memory impact of trying to allocate 20000 objects inside a collection or ArrayList.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
thank you. is there any free online tutorial on this?(i have already searched google)
 
Avoid array by using Hashtable which allow keys (index) on any object for large collections or HybridDictionary for small collections. The limit of Hashtable object is the limit of the heap managed by CLR-Common Language Runtime.
-obislavu-
 
A1METALHEAD -

The URL is surprisingly simple:


Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
um, look, i am relly new to this whole c# thing, i have absolotly have no clue how to do anything. the only way iv been learnig, is from my knowlege in c++. so it would help alot if youd post a direct link to a tut, or you tell me directly how to do somthing. i appreacate all your help alot, but to anyone else im shure you are making complete sence, but becuse of my stupidity could you please simplafly how do do this?i know im dunb, and im probly frustrating to, but could you please make a bit more clearer?
 
This isn't a C# thing -- this is a O-O design decision. C# syntax is something you can look up in the documentation, but learning good design principles will serve you in both C++ and the .NET worlds.

Think of it this way: Design decisions are necessarily abstract, right? So you say things like "I will store my books in a collection". You don't care what kind of collection, or what the API is to use the collection, you're just saying "I need somewhere to store stuff, and the collection is where I'm going to put it".

You then go off and make other decisions, but then come back and re-visit it, this time deciding what type of collection (HashTable). You then go off and refine the rest of the app, making other decisions.

Finally, you're ready to start coding, and this is when you pull out your C# reference.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top