Chapter 3

  Today, the abstract factory pattern is used to improve the instance to achieve dynamic loading of the algorithm instance. The abstract factory pattern belongs to the content of the design pattern. I noticed it when I was studying the video, so I bought this big design pattern before to learn it. It can be said that Learned most of the design patterns. After encountering it today, I also have a bottom line in my heart. After reviewing the book, I know how to do it. It can be said that this is the method I learned.

  In view of the above, an interface is provided in the dll, and both algorithms inherit this interface. The operations of the dll are performed through the interface ISort. In addition, the factory is modified to an abstract factory, an interface creation algorithm is provided, and the ISort instance is returned in the algorithm. , use this instance in the main function to perform the corresponding sorting algorithm operation, which fully demonstrates the role of the abstract factory. This example combines reflection and abstract factory patterns to increase the scalability and maintainability of the program.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325629693&siteId=291194637