结构设计模式和.NET Framework 2.0
原站著录信息
摘要
1.简介 Framework 2.0提供了通用的设计模式,其可重复使用性在设计水平上提供了一些解决问题的方法。这种设计模式没有限定代码,而不是具体某一编程域。相反,它提供了一个证明,测试的解决方案的一类类似的设计问题。该模式也提供共同的术语,我们用其自己设计文件,且使文件更容易理解。 形态描述技术是专家们从多个具体实例中提出的抽象的解决方案。识别和理解提供了两个基本模式的好处。首先, 他们实行有效的设计战略,减轻缺乏经验的设计师们从重新发现这些模式使用的试验和错误。其次他们重视通用名的概念,以便我们可以随时在对话、…
1.简介
Framework 2.0提供了通用的设计模式,其可重复使用性在设计水平上提供了一些解决问题的方法。这种设计模式没有限定代码,而不是具体某一编程域。相反,它提供了一个证明,测试的解决方案的一类类似的设计问题。该模式也提供共同的术语,我们用其自己设计文件,且使文件更容易理解。
形态描述技术是专家们从多个具体实例中提出的抽象的解决方案。识别和理解提供了两个基本模式的好处。首先, 他们实行有效的设计战略,减轻缺乏经验的设计师们从重新发现这些模式使用的试验和错误。其次他们重视通用名的概念,以便我们可以随时在对话、设计和文件中使用。
Structural Design Patterns and .NET Framework 2.0
1 INTRODUCTION
Design Patterns provide generic, reusable designs that solve problems at the design level.A design pattern does not define code and is not specific to a given programming domain.Instead, it provides a proven, tested solution for a class of similar design problems.Design Patterns also lend common terminology that we can use to make our own designs easier to document and understand.
Patterns describe techniques that experts have abstracted from multiple specific solutions. Identifying and understanding patterns provide two essential benefits. First,they introduce effective design strategies to less experienced designers, alleviating them from rediscovering these patterns using trial and error. Second they attach common names to ideas that we can readily use in conversation, design meetings, and documentation.
Design patterns are not created from theoretical examples. Experienced objectoriented designers recognize that certain object structures and interactions lend themselves more readily to maintenance and reusability than others. Just like architects and civil engineers define broad building concepts that apply at many levels, software designers assemble a set of patterns that they can apply to a variety of domains.
Many seasoned designers havewww.51lunwen.org taken the initiative to identify and document patterns. Design Pattern catalogs consolidate related patterns in a single reference collection. The most influential design pattern catalog is the book Design Patterns: Elements of Reusable Object-Oriented Software by Erick Gamma, Richard Helm, Ralph Johnson, and John Vlissides. It identifies and describes 23 patterns that solve broad object-oriented design problems under three categories: Creational, Structural and Behavioral.
Creational patterns abstract the instantiation process. They help make a system independent of how its objects are created, composed and represented. A class creational pattern uses inheritance to vary the class that is instantiated. An object creational pattern will delegate instantiation to another object. Creational patterns give us a lot of flexibility in what gets created, who creates it, how it gets created and when.
Structural Patterns are concerned with how classes and objects are composed to form larger structures. It uses inheritance to compose interfaces or implementations. Structural Patterns describe ways to compose objects to realize new functionality. Behavioral patterns are concerned with algorithms and the assignment of responsibilities between objects. Behavior Class Patterns use inheritance to distribute behavior between classes. Behavior Object Patterns use object composition than inheritance.
The .NET Framework is a suite of products for developing and managing systems with tiered and Object Oriented architectures. A mature framework usually incorporate several design patterns so is .NET framework. The patterns help make the framework’s architecture suitable for many different applications without redesign. An added benefit comes when the framework is documented with the design pattern it uses. This paper is intended to present the .NET versions of the chosen structural patterns. Among the seven structural patterns discussed by Gang of four (GOF), five are explored from the .NET context. A familiarity with design patterns will assist .NET developers, regardless of the language in which they choose to develop, in using the .NET Framework.
This study is not about proposing a new pattern but about presenting the existing patterns in a language .NET designers can understand. The well-known Design Patterns text by the GOF discusses 7 Structural patterns. Among them, five patterns: Adapter, Bridge, Composite, Decorator and Proxy are discussed.
Section 2 shows the architecture of .NET Framework. Sections 3 to 7 explore the chosen five structural patterns. These sections have a brief intent followed by a discussion section in which the pattern’s motivation is discussed. UML class diagram for the patterns is given to make the understanding better. Implementation section considers issues in implementing the pattern in C#. The next section presents the usage of patterns in .NET Framework and the last section talks about the relations between other structural patterns. Conclusion is given in Section 8.
2 .NET FRAMEWORK
.NET Framework is the Microsoft latest technology for developing enterprise-scale ASP.NET Web applications and high performance desktop applications. In addition Microsoft .NET Framework is a platform for building, deploying, and running Web Services and applications. It provides a highly productive, standards-based, Multilanguage environment for integrating existing investments with next-generation applications and services as well as the agility to solve the challenges of deployment and operation of Internet-scale applications. The .NET Framework consists of two main parts: the common language runtime (CLR) and a unified, hierarchical class library that includes a revolutionary advance to Active Server Pages called ASP.NET, an environment for building smart client applications (Windows forms) and a looselycoupled data access subsystem ADO.NET
Comprehensive class libraries
One of the benefits of .NET environment is their large set of base classes for all types of application development. The data types in the framework possess wide-ranging capabilities. Such broad functionality eliminates certain design considerations and even the requirements for some design pattern implementations. For instance, we need not design and implement internal Iterators in .NET because the classes under System.Collections namespace provide their own iteration methods.
The System.Collections.Generic namespace contains interfaces and classes that define generic collections, which allow users to create strongly, typed collections that, provide better type safety and performance than non-generic strongly typed collections. For software development organizations, a renewed (or first) interestwww.51lunwen.org in design patterns is especially relevant today because the common language runtime (CLR) in .NET, within which all managed code executes, is object oriented to the core. This means languages targeted for the common language runtime such as Visual Basic .NET, C#, C++ and J# are fully object oriented and developers can use them to build applications with object-oriented techniques.
