Design Patterns-engineering implementation based on C #

Source: Internet
Author: User

The design pattern is a set of ideas. However, I am a person engaged in coding. Sometimes I often think that we should consider how to implement the Code with application functions more skillfully.

With the help of my masters and colleagues, I have done some work over the past few years. NET project, I love the C # language, so I found that C # has many special features when implementing some design patterns,

Therefore, with the support of teachers Zhou, Chen, and many friends in the QQ group, I think I can summarize some of my previous experiences, so I came up with the idea of writing a book.

 

Although many models of this book have limited extensions, I hope it can be used as an introduction to my discussions with friends who like the model and C # language, I hope this part can be continuously improved.

 

Design Model-engineering implementation and expansion based on C #
Version 4 directory

Article 1: Preparation Content 1
Discover the potential of C # Language Object-Oriented Design 1
Chapter 2 re-study C # Language
2.1 C # part of syntax content Extension
2.1.1 Namespace)
2.1.1.1 embarrassing reality 2
2.1.1.2 namespace planning for enterprise. NET Type Systems Example 3
2.1.1.3 Summary 4
2.1.2 simple asynchronous notification mechanism-delegate 4
2.1.2.1 asynchronous call with Delegate 4
2. 1.2.2 1 Notification to n 5
2. 1.2.3 call anonymous method 7
2. 1.2.4 call the overload method 8
2. 1.2.5 summary 10
2.1.3 test your algorithm abstraction capabilities-generic 10
2. 1.3.1 support for abstract capabilities 10
2. 1.3.2 apply to mode 11
2. 1.3.3 Container 14
2. 1.3.4 type parameter constraints 14
2. 1.3.5 summary 16
2.1.4 extension of Object Features using tags-Attribute 16
2. 1.4.1 guided by Attribute mode 16
2. 1.4.2 further facilitate client program call 19
2. 1.4.3 summary 20
2.1.5 access the C # type information simplified by the indexer 20
2. 1.5.1 serves set 20
2. 1.5.2 encapsulate access to a single column set 21
2. 1.5.3 multi-column set 23
2. 1.5.4 implement access similar to the joint primary key or unique index in RDBMS 24
2. 1.5.5 delegate the transfer of index Rules 24
2. 1.5.6 summary 25
2.1.6 integration with C # Language iteration mechanism-iterator 25
2. 1.6.1 basic application 26
2. 1.6.2 simplify traversal of complex structures 27
2. 1.6.3 summary 31
2.2 Overloadable Operators and Conversion Operators 32
2.2.1 The Day After Someday 32
2.2.2 For finite state iterations 33
2.2.3 operation set 33
2.2.4 type adaptation 35
2.2.5 summary 36
2.3 Configuration System Design for plug-in architecture and on-site deployment
2.3.1 understand the main configuration entity classes provided by. Net Framework 37
2.3.2 application instance 38
2.3.3 summary 46
2.4 implement dependency injection 46
2.4.1 Background 46
2.4.2 Example scenario 47
2.4.3 Constructor injection 49
2.4.4 Setter injection 50
2.4.5 interface injection 51
2.4.6 Attribute-based injection -- Attributer 52
2.4.7 summary 53
Chapter 1 before starting each design pattern
3.1 new () Alternatives 55
3.2 prepare a lightweight memory Cache 57
3.3 prepare a Broker for centralized access to the configuration file 60
3.4 Web? Not Web? 63
3.5 Conclusion 75

Article 2: Creation Mode 76

Chapter 2 Factory & Factory Method)
4.1 simple factory: 77
4.1.1 simplest factory class 77
4.1.2 processing products based on specifications-Parameterized Factory 81
4.1.3 limitations of a simple factory 81
4.2 classic review 81
4.3 decoupling Concrete Factory and customer program 83
4.4 configuration file-based Factory 84
4.5 batch factory 87
4.5.1 development scenario 87
4.5.2 define product type container 88
4.5.3 define a batch factory and product type container 89
4.5.4 Add a production advisor-Director 90
4.5.5 customer program guided by ctor 91
4.6 Generic Factory 93 based on type parameters
4.7 Delegate Factory type Delegate Factory 95
4.8 Summary 96
Chapter 2 Singleton)
5.1 classic review 99
5.2 thread-safe Singleton 102
5.3 Details determine success or failure 104
5.4 fine-grained Singleton 105
5.4.1 background discussions 105
5.4.2 fine-grained Singleton in desktop applications 105
5.4.3 fine-grained Singleton in web applications 107
5.4.4 more general fine-grained Singleton 109
5.5 automatically updated Singleton 120
5.6 parameterized Singleton 121
5.7 Singleton 126 across processes
5.8 Singleton extension -- Singleton-N 127
5.8.1 define an abstract object with execution status 128
5.8.2 define the corresponding Singleton-N instance set 129
5.8.3 introduce the instance set 130 under the framework implemented in the basic Singleton Mode
5.9 introduce configuration file management Singleton 131
5.10 Generic Singleton 132 based on type parameters
5.11 assisted Singleton instance management by factory type 141
5.12 conclusion 141
Chapter 2 Abstract Factory)
6.1 classic review 143
6.2 implement production 146 as planned
6.2.1 Add a type to the abstract factory 146
6.2.2 147 of hard injuries in the processing mode
6.3 define the ing between a plan and production 148
6.3.1 analytics 148
6.3.2 register Mappings
6.3.3 use TypeMapper to assist the factory in producing 150
6.3.4 define entity TypeMapper and entity factory 151
6.3.5 assembly Mechanism 151
6.4 configure the production plan 152
6.5 Delegate-based production outsourcing 155
6.6 conclusion 157
Chapter 2 creator mode (Builder)
7.1 classic review 160
7.2 BuildUp () 162 of asynchronous calls
7.3 create a tag for Builder 165

7.3.1 complete tool 165
7.3.2 define label 166
7.3.3 learn to view tag 167
7.4 Builder 169 with assembly/unload capability
7.5 watch the drawings for processing-register the configuration file 171

7.5.1 convert the UML object to XSD 173
7.5.2 grasp the synopsis-delete the content that is not frequently changed 173
7.5.3 ing to configuration section or configuration element 174
7.5.4 implementing object 175
7.5.5 finished pipeline production 179
7.6 use an iterator to control the pipeline 180
7.7 conclusion 182
7.7.1 Generic Builder183 based on type parameters
7.7.2 analytics 183
7.7.3 process optimization and restructuring 184
Chapter 1 Prototype)
8.1 classic review 186
8.2 surface imitation or in-depth imitation 190
8.2.1 concept 190
8.2.2 create a clone Tool
8.2.3 cloning also requires a slight reserved personality of 193
8.2.4 custom and managed cloning process 194
8.3 redefinition of Prototype Method 196
8.4 support processing of generic set types in both XML and binary serialization
Conclusion 8.5

Article 3: Structural Model 198

Chapter 4 Adapter)
9.1 classic review 199
9.2 further scaling group adapters 202
9.3 Adapter -- Adapter interconnection mode 205
9.3.1 analytics 205
9.3.2 Method 1: client program scheduling Adapter 207
9.3.3 Method 2: Schedule Adapter207 based on standard conventions
9.3.4 method 3: asynchronous call 208 Using Reflection and conventions
9.4 configure the adaptation process 209
9.5 dedicated Adaptation Mechanism for XML data 210
9.6 conclusion 212
Chapter 4 Bridge)
10.1 classic review 215
10.2 multi-level bridge relationships after further decomposing complexity 218
10.3 look at the "drawings" to build bridges 221
10.4 bridges with constraints 223
10.5 conclusion 225
Chapter 4 Composite)
11.1 classic review 228
11.2 use the iterator to traverse the combination type 232
11.3 combination modes suitable for XML Information 234
11.4 conclusion 237
Chapter 2 Decorator)
12.1 classic Review
12.2 decoration modes with self-updating features
12.2.1 analytics 243
12.2.2 abstract decoration Interface
12.2.3 abstract Status Interface
12.2.4 modify decoration based on the current status
12.2.5 test and verification
12.3 design the product of collaboration between Decorator and Builder 248
12.4 tag Decorator
12.4.1 more "thorough" Attribute Injection
12.4.2 Method 1: the. NET platform's built-in AOP mechanism is used to achieve 251
12.4.3 Method 2: Custom proxy interception framework method 254
12.4.4 further analysis 257
12.5 conclusion 257
Chapter 1 Appearance mode (Fa C ade)
13. 1. Classic Review
13.2 Fa C ade interface 262
13.3 Remote Fa C ade 263
13.4 performance-oriented upgraded version Remote Fa C ade-Data Transfer Object mode 266
13.5 abstract Fa-ade interface unrelated to platform and development language -- WSDL 270
13.6 user-friendly Fluent Interface Design 270
13.7 conclusion 272
Chapter 1 Flyweight)
14.1 classic Review
14.2 develop a sharing plan
14.3 comprehensive sharing system-Object Pool 278
14.3.1 background 279
14.3.2 overall technical structure 279
14.3.3 Design of abstract type entity 280
14.3.4 typical application of the metadata-based model -- buffer 280 is not modified
14.3.5 instance 281
14.4 wire-level yuan for Parallel Processing
14.5 Implement Asynchronous Flyweight 285 through Delegate and queue
14.6 conclusion 286
Chapter 2 Proxy)
15.1 classic review 288
15.2 remote access proxy 290
15.2.1 Step 1 Define the remote access service protocol 291
15.2.2 Step 2 define the server configuration file and the corresponding host Program 291
15.2.3 Step 3: generate the client remote Proxy type
15.2.4 Step 4 Write the client program 293
15.3 data access proxy 294
15.4 object cache proxy 296
15.5 add preprocessing and subsequent processing support for the Agent process
15.5.1 Step 1: Define the abstract structure of the external processing mechanism 299
15.5.2 Step 2: Define the configuration information for new processing 300
15.5.3 Step 3: Define the resolution object 301
15.5.4 Step 4: Modify the server and proxy processing process 302
15.6 conclusion 302

Article 4: Behavioral Model 301

Chapter 1 Chain of Responsibility)
16. 1. Classic Review
16.2 use breakpoint to control the chain process
16.3 Chain Reaction
16.4 add configuration Constraints
16.5 conclusion 316
Chapter 4 Template Method)
17.1 classic Review
17.2 meet the requirements of multiple templates
17.3 method template -- Delegate
17.4 type template -- Generic
17.5 templates outlined in configuration
17.6 conclusion 327
Chapter 1 Interpreter Mode)
18.1 classic Review
18.2 use regular expressions
18.3 use a dictionary
18.4 using XSD
18.5 use XSD to explain customized business languages
Conclusion 18.6
Chapter 4 Command)
19.1 classic Review
19.2 lightweight Command-delegate
19.3 asynchronous Command
19.4 package Command
19.4.1 appearance Mode
19.4.2 Combined Mode
19.5 queue commands
19.6 conclusion 362
Chapter 1 Iterator)
20.1 classic review 365
20.2 C # Iterator 367
20.3 conclusion 369
Chapter 2 Mediator)
21.1 classic review 373
21.2 loose coupling of events based on Delegate Mediator 378
21.3 dynamically coordinate notification relationships based on Configurations
21.4 SOAP Mediator
21.5 conclusion 383
Chapter 4 memorandum mode (Memento)
22.1 classic Review
22.2 apply the memo to the stack
22.3 serialization and persistence of Memento 394
22.4 conclusion 397
Chapter 2 Observer mode (Observer)
23.1 classic review 402
23.2 NET built-in Observer mechanism-event 406
23.3 set type with Observer 408
23.4 service-oriented interface-oriented Observer 410
23.5 conclusion 413
Chapter 2 State Mode)
24.1 classic review 416
24.2 State serialization and persistence 420
24.3 active State 423
24.4 triggered State 423
24.5 status transfer involving user interaction 426
24.6 use WF to complete State 426, which is easier to orchestrate
24.7 conclusion 428
Chapter 2 Strategy)
25.1 classic Review
25.2 Strategy and Interpreter collaboration 433
25.3 make full use of the Strategy interface provided by. NET Framework 434
25.4 dynamic policy
25.5 conclusion 438
Chapter 2 Visitor mode (Visitor)
26.1 classic Review
26.2 Visitor 445 with reflection
26.3 use delegation to make the reference relationship more loose
26.4 conclusion 447

Article 5: basic models and application cases of small particles 448

Chapter 1 examples (Idioms)
27.1 Partial Class 449
27.1.1 reflect the composite relationship
27.1.2 profile types from multiple sides
27.1.3 integration with Visual Studio Add-ins 452
27.1.4, summary 452
27.2 Gateway 452
27.2.1 Gateway 453 that encapsulates local APIs
27.2.2 encapsulate non-C # language access interface 455
27.2.3 encapsulation general operation method 455
27.2.4 summary 458
27.3 Mapper 458
27.3.1 description 458
27.3.2 Data Object er
27.3.3 summary 466
27.4 Registry 467
27.4.1 summary 471
27.5 Value Object 471
27.6 general data carriers DataSet and DataTable 473
27.7 Context 474
Chapter 2 GOF summary and application Case (Show Case)
28.1 GOF summary 476
28.1.1 review GOF 476
28.2 application case requirements 476
28.3 discovery and analysis 477
28.4 mode application 480
28.4.1 used mode 480
28.4.2 how to implement specific data sources does not matter 480
28.4.3 provides the ability to customize processing before and after execution 492
28.4.4 design a connection string with a more flexible structure 494
28.5 conclusion 500

Article 6: Part I architecture model 501

Chapter 2 MVC Mode)
29.1 mode introduction 502
29.2 example 504
29.2.1 hybrid mode
29.2.2 responsibilities of decomposition objects
29.2.3 active mode M/V/C 509
29.3 conclusion 512
Chapter 4 pipelines-Pipeline-Filter)
30.1 boarding pipeline process 515
30.1.1 push method initiated by Data Source
30.1.2 pull method initiated by data recipient
30.1.3 push-pull hybrid method initiated by the intermediary object 518
30.1.4 connection method initiated by the data source/data receiver: 519
30.2 example 520
30.2.1 example of Push mode 520
30.2.2 add an active Filter 525
30.3 conclusion 527
Chapter 4 publishing-reservation mode (Pub-Sub)
31.1 "Reservation" that is everywhere in life 529
31.1.1 local observer mode for a single topic 530
31.1.2 added Proxy to implement a single topic-oriented distributed observer mode 530
31.1.3 use publishers to centrally manage reservations 531
31.1.4 design more Publishing Models for physical environments 534
31.2 example 535
31.2.1 data entity model section 536
31.2.2 business entity model Section 539
31.2.3 specific object section 542
31.2.4 unit test 546
31.3 conclusion 548
Chapter 2 Broker Mode)
32.1 more complex distributed system interaction challenges 551
32.2 example 554
32.3 conclusion 557
Chapter 1 Message Bus)
33.1 use bus to sort out the enterprise system environment 561
33.1.1 message bus 563 in separated regions
33.2 conclusion 564

Article 7: some Web and Web Service models 565

Chapter 4 Page Controller mode)
34.1 abstract and expand the page operation logic with Object-oriented Thinking
34.2 example 567
34.3 conclusion 567
Chapter 1 Web service Dependency inversion
35.1 Web Service model features: 569
35.2 first-tier packaging 570
35.3 typical Web Service development methods in the SOA environment: 573
35.4 Dependency inversion principle and applications in Web Services 573
35.4.1 analysis 575
Implementation example 576
35.5 WCF-based engineering implementation 583
Implementation example 583
35.5.2 use the object-oriented features of the WCF Extension Service 587
35.6 conclusion 588
Chapter 2 Web Service Adapter)
Interface adaptation in 36.1Web Service 560
36.1.1 routine scenario analysis 560
36.1.2continuous interaction between Web Services 560
36.1.3 implementation method 562
36.2 example of standard Web Service type 563
36.2.1 data XSD Adaptation: 563
36.2.2 service method compatibility Adaptation: 569
36.2.3 other instructions: 571
36.3 example of using WCF 572
36.3.1 use Data Contract to define Data Schema 573
36.3.2 examples of defining different types of conversions 574
36.4 conclusion 576
Chapter 2 Web Service data transmission object mode (Web Service DTO)
579 performance problems in batch interaction of 37.1Web Service interfaces
37.1.1 DTO object 579
37.1.2 relationship between DTO and consumer services 579
37.1.3 deployment design considerations 581
37.1.4 structure 581
37.2 example 582
37.2.1 583 if no DTO object exists
37.2.2 add DTO object 585
37.3 Conclusion 587
37.4 attachment: 587
37.4.1 two DTO Data Loading Methods 587
Chapter 4 Web Service Event Monitor)
38.1 how to encapsulate the event mechanism for common Web Services 590
38.2 example 591
38.3 conclusion 596
Chapter 2 Web Service Intercepting Filter)
39.1 transparent extension of custom features through interception 599
39.1.1 method 599
39.1.2.NET platform implementation technology 602
39.2 example 604
39.2.1 IHttpModule method 604 Based on ASP. NET Web Service
39.2.2 custom Interception Method Based on WCF 606
39.3 conclusion 610
Chapter 2 Domain Logic Pattern for relational data and XML data)
40.1 main methods to implement business logic 612
40.1.1 overall logical structure 612
40.1.2 Performance Improvement 613
40.1.3 business service design for relational databases 614
40.1.4 XML-oriented extended design 615
40.1.5 configuration Mechanism Design 615
40.2 example 616
40.2.1 Sample Scenario 616
40.2.2 test content preparation 617
40.2.3 actual test process 618
40.3 conclusion 619
Chapter 2 XML-Based Application Model)
41.1 of the world is equal, but more than 621
41.1.1 more Scalable Data Model-XML 621
41.1.2 enable the recognition of unstructured data by 626
41.1.3 integration of data and content 628
41.1.4 New Application Extensions: 630
41.1.5 dealing with Semantic Network Complexity 633
41.2 conclusion 634

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.