Abstract:Object-oriented programming is increasingly pursuing the reusability and flexibility of the program. It is difficult for programmers with less experience to obtain reusable and flexible programs directly. The software design pattern is to extract the experience of object-oriented programmers, and then to summarize them. In the template method pattern, the parent class defines an algorithm framework, uses the template method to specify the execution steps of the algorithm, and delays the variable steps to the subclass implementation. Each different implementation needs to define a new subclass. The system will be larger with maintainability and readability. Therefore, embedding the abstract factory pattern into the template method pattern forms a composite pattern. The core of the composite pattern design is to provide an interface for creating objects for each variable step that is delayed to the subclass. The interface is for a complete definition of product family. The composite mode not only ensures the stability of the algorithm structure, but also separates the specific implementation class, which enhances the robustness, reusability and flexibility of the program.