FactoryMethod mode: defines a factory interface for creating a product object, which delays the actual creation to the subclass. That is to say, the core factory category is no longer responsible for product creation, but only responsible for the interface that must be implemented by the specific factory subclass. The benefits of this abstraction are obvious. We no longer need to modify the role of a specific factory. For example, the following code is a graduating college student who helps an old man in the name of studying Lei Feng's good deeds: [csharp] // LeiFeng {public void Sweep () {Console. writeLine ("sweep");} public void Wash () {Console. writeLine ("laundry");} public void BuyRice () {Console. writeLine (" Mi") ;}// "" class, inheriting from Lei Feng class UnderGraduate: LeiFeng {}// client code static void Main (string [] args) {LeiFeng xueleifeng = new UnderGraduate (); xueleifeng. wash (); xueleifeng. sweep (); xuele Ifeng. buyRice ();} if the number of students is added, for example, three students are required to do these tasks, three "College Students Studying Lei Feng" are instantiated: [csharp] // client code static void Main (string [] args) {LeiFeng student1 = newUnderGraduate (); student1.Wash (); LeiFeng student2 = newUnderGraduate (); student2.Sweep (); leiFeng studen3 = newUnderGraduate (); studen3.BuyRice? Our middle school students can do their best. Therefore, it is not just the problem of instantiating multiple objects. So the Lei Feng factory came. [Csharp] // Lei Feng factory interface ifacloud {LeiFeng CreateLeiFeng ();} // "" factory class UnderGraduateFactory: ifacloud {public LeiFeng CreateLeiFeng () {return new UnderGraduate () ;}// "" factory class MiddleStudentFactory: ifacloud {public LeiFeng CreateLeiFeng () {return new MiddleStudent ();}} the client only needs to do this when calling: [csharp] // client code static void Main (string [] args) {// factory method mode ifacw.factory = NewUnderGraduateFactory (); // change to "middle school student". Modify LeiFeng student = factory. createLeiFeng (); student. buyRice (); student. wash (); student. sweep ();} How is it now? Isn't it easy to change to a middle school student? Through the above code, we can see that the factory method overcomes the disadvantages of a simple factory that violates the "open-closed principle" and maintains the advantages of the encapsulated object creation process, reduces the coupling between customer programs and product objects. It can be said that the factory method mode is further abstract and promoted by the simple factory mode. But there is a problem. When we add a product, we need to add a product factory class. Obviously, it will increase the additional development volume. What should we do? This is to say-"reflection" again. However, this blog will not be detailed, but will be detailed in the future abstract factory model.