CRecordset in where Document or View Class?? 
Author Message
 CRecordset in where Document or View Class??

I have been reading several different books on Visual C++ programming.  I am
creating a simple program that manipulates data in a SQL Server database.  I
am using ODBC recordsets built iwth Class Wizard.  I have been implementing
the code in the view class, everything is working fine.  But I have been
reading about the Document class.  Are you supposed to be accessing the data
from the Document class -or- is the Document class supposed to be used for
writing data to flat files or such?  I am a little confused on this.  In the
books that I have been reading, the examples of accessing a recordset is in
the view class and the document class examples are used for serializing data
to a file.  Can it be done either way -or- is it better to access recordsets
using the view class?  I am just learning Visual C++ programming and I
noticed this.  I would like to program properly, the way MS intended the
language to be used.  I suppose it just doesn't matter and its just a matter
of coding style?

Please help me shed some light on this.

Thanks in advance!!



Tue, 05 Dec 2000 03:00:00 GMT  
 CRecordset in where Document or View Class??

This is a design trade off. The document is supposed to handle all the
data. This includes reading the data, storing it in memory, manipulating
in memory, storing the data, etc, etc. Basically all functions which act
on the data and only data are to be implemented in the document.
The view is supposed to handle the user-interface code. The view is
concerned with getting user input, displaying the data stored in the
document and interacting with the user.

When deciding whether to store the recordset in document or view, ask
urself whether the recordset is the actual 'data' of ur design spec or
is it just temporary information to be used only for a couple of
messages. If  it is just some temporary info, then u might as well use
recordset variables within ur message handlers

If the recordset represents the actual 'data', then there are 2 options
1) store the where clause in the document and open the recordset in the
view as an when needed
This will make ur application slower as every time the recordset is to
be opened
2) keep the recordset in the document and keep it open
This will increase the memory requirements

Use 1) if the recordset is small and/or the where clause parameters keep
changing frequently
Use 2) if the recordset is huge and/or the where clause in constant

WM_HOPETHISHELPS
Jay

Quote:

> I have been reading several different books on Visual C++
> programming.  I am
> creating a simple program that manipulates data in a SQL Server
> database.  I
> am using ODBC recordsets built iwth Class Wizard.  I have been
> implementing
> the code in the view class, everything is working fine.  But I have
> been
> reading about the Document class.  Are you supposed to be accessing
> the data
> from the Document class -or- is the Document class supposed to be used
> for
> writing data to flat files or such?  I am a little confused on this.
> In the
> books that I have been reading, the examples of accessing a recordset
> is in
> the view class and the document class examples are used for
> serializing data
> to a file.  Can it be done either way -or- is it better to access
> recordsets
> using the view class?  I am just learning Visual C++ programming and I

> noticed this.  I would like to program properly, the way MS intended
> the
> language to be used.  I suppose it just doesn't matter and its just a
> matter
> of coding style?

> Please help me shed some light on this.

> Thanks in advance!!



Sun, 10 Dec 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Create mutiple views of one document using different view classes

2. Create mutiple views of one document using different view classes

3. 2 View classes and 1 Document class

4. Splitter view accessing the Document Class

5. Help - can only view classes use document pointers?

6. Document and View class in a different dll

7. View without a document class

8. class roles in a document/view application

9. several view classes and one document

10. Splitter View Accessing the Document Class

11. Multiple View Classes of the same Document

12. Accessing Document Data in 2nd View class

 

 
Powered by phpBB® Forum Software