Introduced as part of version 2.0 of MFC (Microsoft Foundation Classes), the document/view architecture is Microsoft's solution to abstracting out application data, separating it functionally from how that data is displayed. In a document/view application, data used by the document is represented by a document object, and views of that data are represented by different view objects. The application itself becomes a sort of container for the assorted objects held.

Programs using the document/view architecture can use either a single document interface (SDI) or a multiple document interface (MDI). An SDI program can only have one document open per instance, while an MDI program can deal with multiple documents at once. Earlier versions of Microsoft Word used an MDI interface; new versions use an SDI interface and open a new program instance for each document opened.

When used properly, the document/view architecture can be extremely powerful. Spreadsheet data, for example, can be stored in a document object, and displayed as a table in a view object. If, subsequently, the programmer wants to add a chart view for the data, another view object can be created without changing the document object at all. This sort of modularity allows for better code readability and easier code reuse... in theory.

In practice, failure to adhere to the architecture can lead to horrendous code. Because MFC and document/view do so much work "behind the scenes", hacks and kludges can turn a relatively easily understood program into a freakish code nightmare.

Log in or registerto write something here or to contact authors.