java Design Patterns are commonly used in 21 kinds
1. Creative Type: Abstract Factory
[java] View Plain copy package com.seezoon. Create type. Abstract Factory; /** * Abstract Factory * @author DF * Factory method Pattern One problem is that class creation relies on factory classes, that is, if you want to expand the program, * The factory class must be modified, which violates the closure principle, therefore, from the design point of view, there are certain problems, how to solve. * uses an abstract factory model to create multiple factory classes so that once you need to add new functionality, add new factory classes directly, * No need to modify the previous code */ public class abstractfactory { public static void main (String[] args) { ifactory factory = new productafactory (); iproduct product = factory.produce (); product.productmethod (); } } interface IFactory {     PUBLIC IPRODUCT&NBSp;produce (); } class productafactory implements ifactory{ @Override public iproduct produce () { return new producta (); } } class productbfactory implements ifactory{ @Override public IProduct Produce () {         RETURN NEW PRODUCTB (); } } interface iproduct { public void productmethod (); } class producta implements iproduct { @Override &nBsp;public void productmethod () { System.out.println ("ProductA"); }