Mặt tiền-mẫu-là một trong những đơn giản mà vòng ra các nhóm cấu trúc. Mục đích của mô hình này là để cung cấp một giao diện đơn giản với một tập hợp các hệ thống phức đoạn này sử dụng hai tính năng thú vị C #: khởi tạo và liệt kê các loại. | A further elaboration on the theme of creating products is that instead of the client explicitly declaring fields of type ProductA and ProductB say the Product object the builder returns is actually a list of parts which can have different lengths and contents depending on the director that was in charge at its creation. A comparison of the two patterns is given in Table 6-1. Table 6-1. Comparison of Abstract Factory and Builder patterns Criteria Abstract Factory Builder Client aggregates A Factory and Products A Director Builders and a Product Product creation is via A factory A director Product creation invokes CreateProductA Construct builder Factory Builder returns A specific product A part of a product Product has Specific properties A list of parts 138 Chapter 6 Creational Patterns Abstract Factory and Builder CHAPTER 7 Behavioral Patterns Strategy State and Template Method Behavioral patterns are concerned with algorithms and communication between them. The operations that make up a single algorithm might be split up between different classes making a complex arrangement that is difficult to manage and maintain. The behavioral patterns capture ways of expressing the division of operations between classes and optimize how the communication should be handled. In this first chapter on behavioral patterns we ll look at three simple but very useful patterns the Strategy State and Template Methods. Strategy Pattern Role The Strategy pattern involves removing an algorithm from its host class and putting it in a separate class. There may be different algorithms strategies that are applicable for a given problem. If the algorithms are all kept in the host messy code with lots of conditional statements will result. The Strategy pattern enables a client to choose which algorithm to use from a family of algorithms and gives it a simple way to access it. The algorithms can also be expressed independently of the data they are using. Illustration A classic illustration of