Preface: Oh, take the first page, have not responded, it is a big thing to be scared by the brothers, before the directory, ^ _ ^, but don't worry, I will give me a little rest time. Not much to say, let's take a note! ^ _ ^ Design Patterns Notes: Abstract Factory Definition: Provides an interface to create a series of associated or interdependent objects without specifying their specific classes. Provides picking to create an object. Factory mode is our most common mode, which is used to create objects, which is equivalent to creating NEWs of objects. For example, we have a class EXAMPLE, we want to create an object of an Example: eXample eXample = new example (); or Example Example = new example; parameter); if you create an example, it is not like assigning this simple matter, it may be very A long code, if it is also written to the constructor, it is obviously in violation of the principle of object-oriented. We need to separate the responsibility of the creation instance and the responsibility of the use instance, so that the example eXample = new example (parameter); is simple Responsibility: Use an instance of Example; Creating an Example task is handed over to Factory Factory mode. According to the traditional method, if we need to inherit the Example class, generate myexample, you need to define the example for Interface, then constantly inherit this Interface, to generate a lot Subclasses, resulting in such difficult code maintenance. If we start using factory models, we may not have so much trouble. We generate a Factory that is responsible for generating an instance of an Example. Public class factory {public static example {public static example pUBLIC STATICEXAMPLE () {(flag == 1) Return new myexample (); if (flag == 2) return new yourexample ();}} then, then in you In the program, if you want to instantiate myexample. Use example eXample = factory.getIntance (); // There is also other signs, not written. Specific use: The factory model has the following: 1. Simple factory 2. Factory method; 3. Abstract factory. We look at a code public abstract class Factory {public abstract MyExample creator (); public abstract YourExample creator ();} public class FirstFactory extends Factory {public MyExample creator () {......} public YourExample creator () { ...}} public class secondfactory extens factory {public myexample creator () {...} public yourexample creator () {...}} Here we need to create multiple objects, The complexity is improved, and it is necessary to use Abstract Factory to encapsulate common attributes and methods, and different attributes and methods are achieved by subclasses.