青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

C++ Programmer's Cookbook

{C++ 基礎} {C++ 高級} {C#界面,C++核心算法} {設計模式} {C#基礎}

MFC與設計模式

This main topic of this article is to show how patterns are used in MFC. We will be seeing the usage of three patterns in MFC library.

Creational : Singleton Pattern

First step in any MFC application is the creation of application object (object of class derived from CWinApp). There should be only one application object in an instance of MFC application. CWinApp is designed to make sure that only application object is present in a given instance. CWinApp and its descendants are called Singleton Classes. A class (CWinApp or its descendant) that assures a maximum of ONE object of its type at a given time and provides a global access point (AfxGetApp() method) to this object is a Singleton class.

As this principle is applied over and over again to solve recurring object "creational" problems, this becomes a pattern. Singleton Pattern ensures that a class only has one instance and provides a global access point it. The article Creating Singleton Objects using Visual C++ talks about different approaches for implementing Singletons.

Structural : Bridge Pattern

Bridge Pattern is all about decoupling an abstraction (interface) from its implementation so that the two can vary independently. In MFC, the process of storing/retrieving an object to/from a persistence mechanism (like a file) is called Serialization. MFC uses the Bridge Pattern to implement Serialization. CArchive and CFile classes implement object Serialization. CArchive class provides the interface for writing/reading an object to/from a persistence mechanism whereas the CFile and its sub classes provides implementation for different persistence mechanisms such as memory, disk file, sockets etc.

A CArchive object is configured with an object of class CFile (or a derived class) during its construction, from which it obtains the necessary information for serialization, including the filename and type of the requested operation (a read or write). Client performing the Serialization operation can use CArchive object without regarding the persistence mechanism implemented by CFile classes.

The article Bridge Pattern - Bridging the gap between Interface and Implementation talks about Bridge pattern in detail.

Behavioral : Observer Pattern

The Observer Pattern is intended to "Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically". An object that is subjected to change is called a Subject and an object that depends on the Subject's state is called an Observer.

MFC uses a Document/View variant of the Observer Pattern. MFC's famous Document/View architecture uses this variant. A document contains the data object and acts as a Subject. A view is a window object through which the user updates the document and it acts as an Observer. A document can have multiple views. Whenever the data in the document is changed by one of the views, it updates the document by calling UpdateAllViews method, with optional hint about the modification. To inform about the change to other views, the document object calls OnUpdate method for each view attached to it (except the view that called UpdateAllViews). Derived view classes can override the OnUpdate method and update themselves by querying the data from the document.

The article Applying Observer Pattern in C++ Applications talks about Observer pattern in detail.

Summary

Design Pattern provides a common language for designers and helps them to decompose systems into a set of cooperating classes and objects. They provide proven design solution to recurring problems. In this article, I have introduced the design pattern and how MFC is using some of the patterns in its design. We can easily find more and more patterns when we dig into MFC and its classes.

posted on 2006-05-25 13:39 夢在天涯 閱讀(3804) 評論(0)  編輯 收藏 引用 所屬分類: CPlusPlusMFC/QTDesign pattern

公告

EMail:itech001#126.com

導航

統計

  • 隨筆 - 461
  • 文章 - 4
  • 評論 - 746
  • 引用 - 0

常用鏈接

隨筆分類

隨筆檔案

收藏夾

Blogs

c#(csharp)

C++(cpp)

Enlish

Forums(bbs)

My self

Often go

Useful Webs

Xml/Uml/html

搜索

  •  

積分與排名

  • 積分 - 1817009
  • 排名 - 5

最新評論

閱讀排行榜

青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
      <noscript id="pjuwb"></noscript>
            <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
              <dd id="pjuwb"></dd>
              <abbr id="pjuwb"></abbr>
              久久xxxx精品视频| 欧美在线一二三区| 亚洲国产另类 国产精品国产免费| 欧美在线视频免费播放| 国产一区91| 久久野战av| 免费观看亚洲视频大全| 亚洲精品美女在线| 99热这里只有精品8| 国产精品国产自产拍高清av王其| 午夜精品久久久久久久| 亚洲欧美99| 一区二区在线观看视频| 亚洲国产99精品国自产| 欧美日韩国产色视频| 午夜精品久久久久久99热软件| 香蕉久久夜色精品国产使用方法| 国产一区二区三区在线观看网站 | 欧美日本视频在线| 亚洲一区二区在线看| 午夜亚洲一区| 亚洲国产日韩在线| 在线视频你懂得一区| 国内精品久久久久影院薰衣草| 亚洲福利视频专区| 国产精品福利在线观看| 乱中年女人伦av一区二区| 欧美激情bt| 久久精品国产欧美激情| 欧美a级大片| 欧美综合77777色婷婷| 欧美69视频| 欧美在线二区| 欧美欧美午夜aⅴ在线观看| 久久大香伊蕉在人线观看热2| 欧美va天堂va视频va在线| 香蕉av777xxx色综合一区| 欧美不卡激情三级在线观看| 午夜精品久久久久99热蜜桃导演| 噜噜噜久久亚洲精品国产品小说| 亚洲欧美日韩中文视频| 久久综合九色欧美综合狠狠| 西西人体一区二区| 欧美理论片在线观看| 久久综合99re88久久爱| 国产精品男女猛烈高潮激情| 亚洲国产成人精品久久| 国内精品嫩模av私拍在线观看| 日韩午夜剧场| 最新日韩精品| 久久香蕉国产线看观看av| 性欧美1819性猛交| 欧美三级欧美一级| 欧美激情第五页| 一区二区三区在线视频播放| 亚洲欧美激情在线视频| 亚洲尤物影院| 欧美日韩中文另类| 亚洲三级观看| 99精品99| 欧美精品一区二区三区四区| 欧美第一黄网免费网站| 黄色在线一区| 久久九九热re6这里有精品| 欧美中文字幕视频在线观看| 国产精品一区二区久久久| 一区二区三区欧美| 亚洲一区黄色| 国产精品超碰97尤物18| 在线一区二区日韩| 亚洲中午字幕| 国产精品女同互慰在线看| 夜夜嗨一区二区三区| 亚洲在线一区二区| 欧美午夜久久久| 亚洲欧美日韩精品久久| 久久av红桃一区二区小说| 国产精品有限公司| 欧美在线高清| 欧美成人自拍| 亚洲蜜桃精久久久久久久| 欧美精品福利| 一区二区日韩欧美| 久久九九久久九九| 在线播放日韩欧美| 欧美sm视频| 一本色道久久综合亚洲精品婷婷| 亚洲在线网站| 国产一区二区三区成人欧美日韩在线观看 | 国产亚洲福利一区| 久久久国产成人精品| 亚洲第一页中文字幕| aa国产精品| 国产精品自拍视频| 久久久夜色精品亚洲| 亚洲精品一线二线三线无人区| 亚洲欧美日韩在线| 狠狠色综合色区| 欧美精品一区二区三区蜜桃| 亚洲——在线| 欧美电影在线观看完整版| 亚洲一级在线| 韩国美女久久| 欧美三日本三级少妇三2023| 欧美在线资源| 日韩视频在线一区二区三区| 久久精品盗摄| 一区二区av在线| 国产性天天综合网| 欧美日韩高清在线观看| 久久九九精品| 亚洲中字在线| 亚洲精品国产系列| 久久综合影视| 午夜精品成人在线| 91久久香蕉国产日韩欧美9色| 国产精品视频1区| 欧美国产日韩在线| 欧美一区二区三区四区夜夜大片| 亚洲人永久免费| 老司机一区二区三区| 亚洲欧美国产视频| 99re66热这里只有精品3直播| 狠狠入ady亚洲精品| 国产精品xvideos88| 欧美精品三级| 久久综合电影一区| 欧美在线观看视频一区二区三区| 一本一本久久| 亚洲人成在线观看一区二区| 嫩草国产精品入口| 久久男女视频| 欧美在线亚洲在线| 亚洲欧美在线另类| 在线性视频日韩欧美| 日韩午夜中文字幕| 亚洲日本视频| 91久久香蕉国产日韩欧美9色| 国产在线视频不卡二| 国产精品一级二级三级| 国产精品免费福利| 国产精品麻豆va在线播放 | 99在线精品免费视频九九视| 欧美激情中文字幕在线| 免费亚洲一区二区| 另类尿喷潮videofree| 久久麻豆一区二区| 久久免费视频在线| 欧美成人精品1314www| 欧美www在线| 你懂的网址国产 欧美| 欧美成人午夜激情视频| 欧美波霸影院| 欧美激情在线| 亚洲另类一区二区| 日韩视频一区| 亚洲——在线| 久久精品国产精品亚洲| 久久久精品一区| 免费亚洲视频| 欧美日韩91| 国产精品女人毛片| 国产一区视频网站| 亚洲电影中文字幕| 亚洲最黄网站| 欧美一区二区三区精品 | 在线免费观看日本欧美| 亚洲国产毛片完整版| 日韩一级免费观看| 欧美一级大片在线观看| 久久久久综合网| 欧美激情一区二区三区在线| 日韩视频一区二区三区在线播放| 亚洲婷婷在线| 久久女同精品一区二区| 欧美久久久久久久| 国产欧美大片| 最新国产成人在线观看| 亚洲欧美日韩视频一区| 久久夜色精品亚洲噜噜国产mv| 亚洲国产视频a| 亚洲免费在线视频一区 二区| 久久久久久夜精品精品免费| 欧美日韩伊人| 一区二区三区在线免费播放| 中国亚洲黄色| 久久久久久久精| 99成人在线| 久久字幕精品一区| 国产麻豆91精品| 日韩亚洲一区二区| 久久一区二区三区四区| 亚洲靠逼com| 久久久久国产精品厨房| 国产精品家庭影院| 亚洲黄色免费| 久久夜色精品国产欧美乱| 亚洲图色在线| 欧美日韩一区二区三区免费看 | 欧美日韩精品在线播放|