Six principles of design pattern:
1. Single Responsibility Principle
There should never is more than one reason for a class-to-change.
2. Interface Isolation principle
Clients should not being forced to depend upon interfaces that they don ' t use.
The dependency of one class to another one should depend on the smallest possible interface.
3. Dependency Inversion principle
The modules should not depend upon low level modules. Both should depend upon abstractions. Abstractions should not depend upon details. Details should depend upon abstractions.
4. Minimum knowledge rule
Least Knowledge Principle
5. The Richter replacement principle
Functions that use pointers or references to base classes must is able to use objects of derived classes without knowing I T.
6. Opening and closing principle
Software entities like classes,modules and functions should is open for extension but closed for modifications.
23 Different design modes
1. Single-case mode
Ensure a class have only one instance,and provide a global point of access to it. (Make sure that one class has an instance, and instantiate it yourself and provide it to the entire system.) )
Define a private access constructor for your own new object, avoid the other class new object, and provide a way for the outside world to access the object.
2. Factory mode
Define an interface for creating a object,but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses. (Define an interface for creating objects so that subclasses decide which class to instantiate.) The factory method defers the instantiation of a class to its subclasses. )
3. Abstract Factory mode
Provide an interface for creating families of related or dependent objects without specifying their concrete classes. (To create a Group-dependent or interdependent objects provide an interface and do not need to specify their specific classes. )
4. Template Method Mode
Define The skeleton of a algorithm in a operation,deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm ' s structure. (Define an operation The framework of the algorithm, and some steps are deferred to the subclass. Enables subclasses to redefine some specific steps of the algorithm without altering the structure of an algorithm. )
5. Builder mode
Separate the construction of a complex object from it representation so, the same construction process can create dif Ferent representations. (Separates the construction of a complex object from its representation so that the same build process can create different representations.) )
6. Proxy mode
Provide a surrogate or placeholder for another object to control access to it. (Provides a proxy for other objects that controls access to this object.) Many other patterns, such as state mode, policy mode, and visitor pattern, are essentially delegate patterns in more specific situations.
7. Prototype Model
Specify the kinds of objects to create using a prototypical Instance,and create new objects by copying this prototype. (With prototypes Instances specify the kinds of objects that are created and create new objects by copying those prototypes. )
8. Broker Mode
Define an object, encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to all other Explicitly,and it lets you vary their int Eraction independently. (Encapsulates a series of object interactions with a mediation object, which causes the objects to be loosely coupled and can independently change the interaction between them without showing the interaction of the objects. )
9. Command mode
Encapsulate a request as an Object,thereby letting are parameterize clients with different requests,queue or log requests, and support undoable operations. (Encapsulates a request as an object, allowing you to parameterize the client with different requests, queue requests, or log request logs, which can provide undo and redo functions for the command.) )
10. Responsibility Chain Mode
Avoid coupling the sender of a request to their receiver by giving + than one object a chance to handle the request. Chain the receiving objects and pass the request along the Chain until an object handles it. (enables multiple objects to have the opportunity to process the request, thus avoiding the sender and recipient of the request The coupling relationship between the. Link the objects to a chain and pass the request along this chain until an object has processed it. )
11. Decoration Mode
Attach additional responsibilities to an object dynamically keeping the same interface. Decorators provide a flexible alternative to subclassing for extending functionality. (dynamically add some extra responsibilities to an object.) For added functionality, the adornment mode is more flexible than generating subclasses. )
12. Policy mode
Define a family of algorithms,encapsulate each one,and makes them interchangeable. (Define a set of algorithms that encapsulate each algorithm and make them interchangeable.) )
13. Adapter Mode
Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn ' t otherwise because of incompatible interfaces. (Transforms the interface of one class into the other interface that the client expects, thus The two classes that were originally unable to work together because of an interface mismatch could work together. )
14. Iterator Mode
Provide a-from access the elements of an aggregate object sequentially without exposing its underlying representation. (IT Provides a way to access individual elements in a container object without exposing the object's internal details. )
15. Combination Mode
Compose objects into the tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly. (Combines objects into a tree structure to represent a "partial-whole" hierarchy, Makes the user consistent with the use of individual objects and composite objects. )
16. Observer mode
Define a one-to-many dependency between objects so then one object changes State,all its dependents is notified and Updated automatically. (Defines a one-to-many dependency between objects, so that whenever an object changes state, all objects that depend on it are notified and automatically updated.) )
17. Façade mode
Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use. (Requires that a subsystem's external communication with its internal must be done through a unified object.) Façade mode provides a high-level interface that makes subsystems easier to use. )
18. Memo Mode
Without violating Encapsulation,capture and externalize an object ' s internal state so, the object can be restored to T His state later. (without compromising encapsulation, capture the internal state of an object and save it outside that object.) The object can then be restored to its previously saved state. )
19. Visitor Mode
Represent Anoperation to being performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it operates. (Encapsulating some of the effects of a data structure The operation of each element, which can define new operations acting on these elements without altering the data structure. )
20. State mode
Allow a object to alter it behavior when it internal state changes. The object would appear to changes its class. (When an object's internal state changes to allow it to alter its behavior, it looks like it has changed its classes.) )
21. Interpreter Mode
Given a language,define a representation for it grammar along with an interpreter that uses the representation to INTERPR Et sentences in the language. (given a language, define a representation of its grammar and define an interpreter that uses that representation to interpret sentences in the language.) )
22. Enjoy meta mode
Use sharing to support large numbers of fine-grained objects efficiently. (using shared objects effectively supports a large number of fine-grained objects.) )
23. Bridge mode
Decouple an abstraction from the IT implementation so and the two can vary independently. (decoupling abstractions and implementations so they can vary independently.) )
Outline of java23 design patterns