Data and View
In our previous examples of CArchive we have taken member variables of CStudent class and showed how to save and retrieve data to and from file stream.
Again there was a diaglog example to exchange student data attributes between UI and these member variables. Here we have data and display UI part in one single dialog file.
We write small applications and we often do data management and data display part in a single module. This is however is not a good design. We face design issues when we scale up our application and deals with multiple data modules.
There is a design need to have different modules to manage data and display separately.
Document View Architecture
MFC Document View Architecture is a framework to manage user module data and view of the module separately.
The design it follows is known as model-view architecture. Data part is managed by model and in MFC this is known as Document and display part is managed by view class.
Document is the class to manage data part of the objects. Application often derives a class from CDocument. This deals with saving and retrieving data fields to and from the file stream. MFC often uses CArchive and serialization process to do the same. Users however have other options like direct CFile calls to synch the data to file syatem or query SQL server to do the same. Document module also deals with the logic to maintain the data and also responsible for managing different attributes of the data.
View is the class module to display data of the document. A derived class of CView is often used for this purpose. This display part can be the display of the document in graphical form or with UI elements or in the form of printable view which contains formatted text.
MFC framework uses a Frame window or class CFrame to display window in the screen and thus a CFrame class is always needed in any application which follows document view architecture.
Document View Block diagram
Document and View Advantages
This design may look complex for a small dialog based application. However this actually helps when dealing with a large application where there are multiple data objects and different view of the objects. This design decouples data from view.
Data managing part may go separate changes where display part can remain unchanged. Again there can be display part to change where data manage part can remain same.
For both the cases this design fits well. There are possibilities that there is need to change the entire interface of document save retrieve part. Say we have migrated from CArchive data file to database thus the entire data logic part can be changed independently.
Again view can also be changed independently. Say we migrated to HTML view from dialog view then also changes in view part can be independent.
Doc view architecture can also fits well for the documents for multiple views like a document of student object can be viewed in dialog when taking inputs from user then same can be in graphical page view when we print of display for viewing.
You have viewed 1 page out of 109. Your VC++ learning is 0.00% complete. Login to check your learning progress.
Similar topics related to this section
Programming Windows, Fifth Edition (Developer Reference)
Programming Applications for Microsoft Windows (Microsoft Programming Series)
Programming Windows with MFC, Second Edition
Visual C++ Programming
Programming Microsoft Visual C++, Fifth Edition
| #1 webmaster Sun 27 Apr/2014 01:38:50(GMT) || 0 || 0|
We are pleased to inform you that a forum/blog has been incorporated with www.mybestnotes.co.in. You are welcomed to add your comments, requests, codes, solutions and feedback to it. Please login(if already a member) or signup(for free) to avail to this facility.
Your message goes here: