Design mode commonly used in Windows application development

xiaoxiao2021-03-06  60

This article describes some of the design patterns commonly used in Windows application development. It is worth mentioning that there are no many recognized patterns in the Windwos platform. The three design patterns introduced herein come from Microsoft websites and some technical books.

This article mainly introduces two modes: MIKE MCCLURE (Microsoft) Entity-Collection-Class (ECC) mode proposed on MSDN, and Bryan Costanich derived from ECC Mode Derived Manager-Collection-Class (MCC) mode, other Wadee Baron mentioned in "Designing Solutions With COM Technologies" Review the reference information at the end of the article.

Entity-Collection-Class mode

Engine-Collection-Class Design Mode divides one entity component into both part of Engine, Collection, and Class. Class is a usual business / entity object, with an entity representing the real world. Engine and Collection provide methods for managing and expanding its behavior. For entities to be modeled, all these three elements must be created.

Figure 1. ECC design pattern relationship diagram

ECC isolates the entity's creation, storage, and properties to provide a three-layer design for business objects. The ECC design mode uses object-oriented technologies (such as packages) and some popular design patterns (such as Object Factory and Opaque Object Adapter).

Typically, Engine implements a design pattern called Object Factory, which defines an interface to create other objects. In this case, Engine creates both Collection objects and creates a Class object. Design Engine in this way provides the following benefits:

Provide check and mandatory objects created by a single interface control and mandatory object to provide loose coupling between clients and CLECTION and CLASS objects, which increases new features without affecting customer machine known valid status. Object creation

Collection implements a mode called Opaque Object Adapter, which allows an object to package and use another object interface and functionality. As shown in Figure 2, Collection contains a reference to ConcreteInternalStorage. This is called synthesis. The ConcreteInternalStorage object is used to store the Class object, and it can also be used to provide extended features for Collection based on the provided features. Array, .NET Framework list objects, Dictionary objects, and ADO records are examples of ConcreteInternalStorage objects. This makes Collection provide the following benefits:

Implementation Inheritage By changing the loose coupling between the ConcreteinternalStorage object enhances the internal storage object between the CONCRETEINTERNALSTORAGE object, allowing object changes to generate minimal impact on the client, or does not affect the ability to handle Class objects (such as calculation, count)

Class provides access to entity data, which manages the status of its own object, such as Dirty, isnew interface. Figure 2 is a reference model for an ECC mode.

Figure 2. Engine-Collection-Class Model

The ECC mode is more complex, complete design ideas to see Engine-Collection-Class, A Design Pattern for building reusable Enterprise Components.

Manager-Collection-Class mode

The MCC is derived from ECC. Unlike ECC, the ECC's Collection class is responsible for the creation of specific entities, and Engine provides this external access. In the MCC mode, only use as an object container, and Manager provides external access, most In addition, it is responsible for the maintenance of the entity, so the MCC mode is actually often used as a Manager-Class. Create a complete MCC model, you need to create 3 classes: ObjectManager, ObjectCollection, Object. Complete business entity is shown below:

The following MCC model graph helps understand the relationship between three classes

ObjectManager

ObjectManager management data storage, including gain, persistence, update, and delete objects or objects. ObjectManager manages data storage, including writing access data creation business objects, for greater reuse, can also consider accessing processing data acquisition and persistence function abstraction in an ObjectDataManager class.

ObjectCollection

ObjectCollection inherits to the .NETD framework class ArrayList (can also be implemented in a Vector), which can manage the collection item and implement the IEnumerable (.NET Framework class) interface, which can be bound to the list control. The ObjectCollection class can increase additional methods, such as sorting according to the properties of the object. ObjectCollection is not responsible for persistent management. In general, ArrayList can meet MCC's collection requirements, so it can be more simplified.

Object

Object describes the properties of data that requires maintained on an object, such as a User object, which is not connected to a database. When the data changes of the object, the Boolean flag isDirty should be set to true. Object itself does not know how to "save" or "update", it needs to pass back to the ObjectManager class to implement these features. In addition, the object collection of the ObjectCollection class can also be passed to ObjectManager for persistence management.

Complete Description of MCC Mode See Engine-Collection-Class, A Design Pattern for Building Reusable Enterprise Components, ENTERPRISE COMPONENTS

Reference

books

"Designing Solutions with COM TECHNOLOGIES", Wade Baron, English "COM Technology Solutions Design", Wade Baron, Machinery Publishing, 2001.09, Chinese version

article

Engine-Collection-Class, A Design Pattern for Building Reusable Enterprise Componentsmcc Design Pattern (Draft) (Microsoft Word format)

转载请注明原文地址:https://www.9cbs.com/read-117967.html

New Post(0)