Abstract Factory: one problem with the Factory method mode is that the creation of classes depends on the Factory class. That is to say, if you want to expand the program, you must modify the Factory class, this violates the closure principle. Therefore, from the design perspective, how can we solve certain problems? The abstract factory mode is used to create multiple factory classes. Once new functions need to be added, new factory classes can be directly added without modifying the previous code. Because the abstract factory is not very easy to understand, let's take a look at the figure first, and then it is easier to understand with the code. Interface class: [java] public interface Sender {public void Send ();} implementation class: [java] public class MailSender implements Sender {@ Override public void Send () {System. out. println ("this is mailsender! ") ;}} [Java] www.2cto. compublic class SmsSender implements Sender {@ Override public void Send () {System. out. println (" this is sms sender! ") ;}} Factory class: [java] public class SendMailFactory implements Provider {@ Override public Sender produce () {return new MailSender ();}} [java] public class SendSmsFactory implements Provider {@ Override public Sender produce () {return new SmsSender () ;}} abstract interface class: [java] public interface Provider {public Sender produce ();} Test class: [java] public class Test {public static void main (String [] args) {Provide R provider = new SendMailFactory (); Sender sender = provider. produce (); sender. the advantage of the Send () ;}} mode is that if you want to add a function: Send timely information, you only need to create an implementation class to implement the Sender interface, at the same time, make a factory class to implement the Provider interface, and it will be OK, without modifying the ready-made code. In this way, the scalability is better!