ConceptMultiple factory models are an improvement to the common factory approach, where, in normal Factory mode, objects are not created correctly if there is an error in string delivery, and multiple factory modes provide multiple factory methods to create the objects individually.multiple Factory mode diagramsMultiple Factory mode We only need to refer to (http://www.cnblogs.com/MrMedici/p/7895248.html) Snedfactory This class to modify the line, as follows: Multiple factory modes are created as follows: public class sendfactory {Mail Send Factory mode public sender Producemail () {return new MailSender (); Mail Sender Factory mode public Sender Producesms () {retur N New Smssender ();}} The test class is as follows: [Java] View Plaincopypublic class Factorytest {public static void main (string[] args) {Sendfactory factory = new Se Ndfactory (); Sender sender = Factory.producemail (); sender. Send (); }} Output: This is mailsender!
Java design mode-multi-Factory mode