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

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 夢在天涯 閱讀(3802) 評論(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

搜索

  •  

積分與排名

  • 積分 - 1816649
  • 排名 - 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>
              亚洲免费在线| 欧美一区二区精品在线| 久久综合网hezyo| 尤物精品在线| 欧美国产高清| 欧美日韩国产色综合一二三四 | 欧美在线一区二区三区| 国产精品视频免费在线观看| 欧美亚洲一级| 久久精品一本| 亚洲精品网站在线播放gif| 亚洲精品一区二区三区樱花| 国产精品成av人在线视午夜片| 午夜视黄欧洲亚洲| 欧美一区二区私人影院日本| 在线观看91精品国产入口| 欧美激情一区二区三区在线视频 | 乱人伦精品视频在线观看| 亚洲精品日本| 亚洲午夜av电影| 亚洲国产裸拍裸体视频在线观看乱了| 亚洲国产精品久久久| 欧美精品在线一区二区| 久久av红桃一区二区小说| 老司机精品视频一区二区三区| 日韩视频在线观看| 欧美亚洲视频一区二区| 亚洲人成77777在线观看网| 在线亚洲自拍| 在线免费高清一区二区三区| 亚洲精品裸体| 黑人巨大精品欧美一区二区小视频| 欧美激情精品久久久久久蜜臀| 国产精品每日更新在线播放网址| 免费一级欧美在线大片| 国产精品人成在线观看免费 | 欧美在线观看视频一区二区三区 | 久久久91精品国产一区二区三区| 夜夜嗨av一区二区三区四季av| 亚洲欧美视频在线| 中文一区在线| 欧美99在线视频观看| 久久久久成人精品| 国产精品第十页| 亚洲精品一区二区三区四区高清| 伊人久久大香线蕉av超碰演员| 亚洲性人人天天夜夜摸| 日韩一二在线观看| 免费日韩一区二区| 麻豆成人综合网| 国产偷自视频区视频一区二区| 日韩午夜一区| 日韩一区二区精品视频| 久久免费黄色| 久色成人在线| 国产亚洲欧美一区二区三区| 亚洲一区二区三区精品动漫| 亚洲一区二区不卡免费| 欧美极品欧美精品欧美视频| 欧美高清在线| 亚洲国产婷婷| 欧美成人高清| 91久久黄色| 日韩亚洲一区二区| 欧美日韩视频在线一区二区| 亚洲欧洲精品成人久久奇米网| 亚洲黄色视屏| 欧美精品导航| 亚洲美女中文字幕| 亚洲视频一区二区在线观看| 欧美伦理91i| 一区二区高清在线| 亚洲欧美激情精品一区二区| 国产精品久久久99| 亚洲一区在线播放| 欧美中文在线免费| 国产午夜精品视频| 久久午夜精品一区二区| 老司机精品视频网站| 极品尤物av久久免费看| 久久久久久自在自线| 亚洲高清免费视频| aa国产精品| 国产精品普通话对白| 亚洲综合激情| 久久一区视频| 日韩一级视频免费观看在线| 欧美日韩亚洲一区二| 亚洲视频1区2区| 久久精品免费看| 亚洲国产三级| 国产精品美女午夜av| 欧美一级成年大片在线观看| 欧美国产大片| 亚洲综合日韩中文字幕v在线| 国产精品一区二区久久久久| 久久久亚洲成人| 亚洲人成在线观看一区二区| 亚洲免费在线观看| 国产区在线观看成人精品| 另类酷文…触手系列精品集v1小说| 亚洲国产视频一区| 欧美一区二区精品| 亚洲人成在线播放| 国产麻豆综合| 欧美日韩成人在线视频| 性欧美xxxx大乳国产app| 亚洲欧洲精品一区二区三区| 欧美一区永久视频免费观看| 亚洲激情av| 国产一区二区精品久久91| 欧美精品一区二区三区蜜臀| 午夜久久资源| 一本色道久久88亚洲综合88| 欧美1区2区视频| 亚洲影院污污.| 日韩午夜免费| 在线日韩中文| 国产午夜精品麻豆| 国产精品毛片一区二区三区| 欧美精品18+| 久久婷婷激情| 久久精品国产69国产精品亚洲| 亚洲精品社区| 欧美韩日一区二区三区| 久久久久www| 欧美一区二区日韩一区二区| 99re亚洲国产精品| 亚洲精品久久久久久久久久久| 国语自产精品视频在线看一大j8| 国产精品久久久久久妇女6080| 欧美激情第五页| 蜜桃av久久久亚洲精品| 久久久精品动漫| 久久er精品视频| 香蕉久久一区二区不卡无毒影院 | 亚洲电影av| 欧美电影免费观看高清| 久热成人在线视频| 久久人人爽爽爽人久久久| 欧美一区二区精品在线| 亚洲欧美视频在线| 亚洲男人第一av网站| 亚洲欧美日韩另类| 亚洲欧美视频| 欧美在线观看视频| 久久久99免费视频| 久久亚洲一区二区| 免费精品视频| 亚洲国产精品女人久久久| 欧美激情一区二区三区全黄 | 久久久久久久久岛国免费| 久久aⅴ国产紧身牛仔裤| 久久爱www久久做| 久久婷婷国产麻豆91天堂| 久久精品国产成人| 久久久久久97三级| 免费亚洲网站| 亚洲精品黄网在线观看| 亚洲美女区一区| 亚洲一区三区视频在线观看| 欧美亚洲免费高清在线观看| 欧美一区亚洲一区| 久久只有精品| 欧美日韩色婷婷| 国产精品日韩在线观看| 国产在线精品一区二区夜色| 在线观看视频亚洲| 宅男在线国产精品| 久久精品亚洲一区二区| 欧美v日韩v国产v| 91久久久久久久久久久久久| 中国亚洲黄色| 久久免费少妇高潮久久精品99| 欧美国产第一页| 国产欧美精品一区| 亚洲另类在线视频| 中文高清一区| 老司机一区二区| 一本色道久久加勒比88综合| 欧美一区视频在线| 欧美美女操人视频| 狠狠色狠狠色综合日日五| 亚洲乱码国产乱码精品精天堂| 亚洲欧美成aⅴ人在线观看| 欧美14一18处毛片| 亚洲一区二区三区免费在线观看 | 欧美高清在线播放| 国产精品日本欧美一区二区三区| 狠狠综合久久av一区二区老牛| 亚洲精品国产欧美| 久久国产精品久久久久久| 亚洲激情国产| 久久久www成人免费精品| 欧美无乱码久久久免费午夜一区| 伊人久久综合| 欧美在线观看视频在线| av成人免费在线| 欧美大尺度在线观看| 国内成人精品视频|