"Chris" <
[email protected]> a écrit dans le message de
[email protected]...
| The app itself has 1 main form with a listview. Three types of journal can
| be generated, each journal is a separate form with 5-20+ items of user
input
| being saved to a respective class.
| Instances of these objects are stored in a List<T>, and information from
| them is stored in the listview. The listview can be double clicked to edit
| selected items (buttons and menus create this functionality too), items
can
| also be deleted in this manner. The items in list view can be sorted on a
| number of criteria (dates, word search, journal type) and a combo box
allows
| the display of specific item types only in the listView. Other data
| structures store wordlists used to colour specific words found in a
journal
| text body.
| All the data contained in the journals in processed in a variety of ways
to
| produce a number of statistics.
|
| The above is the main functionality of the application. The application
| should store hundreds/thousands of journal entries at a minimum.
|
| I thought that holding so many objects (some with large bodies of data in
a
| rtf form) in memory would make the application a huge memory hog, and
| interfacing with a DB could possibly draw off only the items needed e.g.
| listview will search the DB and draw the information it needs only. Double
| clicking an item will cause the rest of the selected journal to be drawn
| from the database and used to populate a form for editing etc.
You really must separate the areas of displaying, managing and storing
objects
Ideally, large quantities of objects should be *stored* in a database.
How the objects are *managed* depends on quantities and other intangibles.
If you want to manage large quantities, then you would consider building a
broker which will page the objects into an in-memory list as required
*Displaying* the objects requires that your UI components will "ask" the
list for items, either on a one by one basis or a page at a time.
If you build your list class correctly, then it can surface events which can
be handled by a broker. The idea being that when the list is asked for, say,
item 45, the GetItem method would check to see if that item had already been
retrieved and, if not, would fire the ItemRequired event passing the index
required; the broker would note the index and check how many objects would
have to be retrieved to cover that index number. IT is always best to page
objects to save time, so 45 on a 10 page strategy would mean loading at
least four pages of objects.
You could also remove unused objects when they are no longer required, but
this will depend on the speed requirements of the program as to whether this
is reasonable or not.
Sorting objects that have been stored in a database and which are being
drawn into a list is usually best done by issuing SQL against the database
with a sort clause. Sorting the list means calling a Sort method on the list
class which is used to fire an event which is captured by the broker, which
will reload the list with objects sorted in the required order.
As to populating "large" objects; you are best working with partially loaded
objects for the purposes of browsing in a list, only loading all the
properties when a full object is selected for editing.
Looking at your message, it would seem like you are moving in this direction
anyway
Joanna