patterns, and the book has been recognized as a cornerstone in the field of design patterns.Some basic principles of object-oriented1. For abstract principlesWhen designing a class, do not let the class target a specific class, but instead target an abstract class or interface.For example: Define a cylinder with a triangular bottom face2. Open-Close principleThe design
, the subject of this book is still close to the object-oriented and design pattern theory. This book revolves around designing an example of a document editor that explains a variety of design patterns, such as creational patterns, Structural and behavioral
pattern is to encapsulate some action that is applied to a data structure element. Once these operations need to be modified, the data structure that accepts the operation can remain unchanged. The visitor pattern is suitable for systems with relatively indeterminate data structures, which frees up the coupling between the structure and the operation of the structure so that the set of operations can evolve relatively freely. The visitor pattern makes it easy to add new operations, which is to
23 design patterns (21) java meta-mode and 23 Design Patterns
Dr. Yan Hong's book "JAVA and patterns" describes the Flyweight mode as follows:
In boxing, Flyweight refers to the most li
that the coffee subclass and the tea sub-class implement both methods public class Coffee extends beverage {@Override protected void Putintocup () {System.out. println ( "Put the coffee in the Water Cup" protected void Addcondiments () {System.out.println ( "Add sugar and Milk" Public class extends Beverage { @Override protectedvoid Putintocup () { System.out.println ( "Put the coffee in the Water Cup"); @Override protectedvoid addcondiments () { Syst
, for a dependent class, regardless of how complex the logic is, try to encapsulate the logic inside the class as much as possible. Outside of the public method provided. Incorrect external leaks no matter what information.It's a little hard to remember. Summary is:father1Opening and closing principleThis is nothing to say: try to make changes by extending the behavior of the software entity rather than changing the existing code. Transfer from http://blog.csdn.net/cq361106306/article/details/38
now requiredAdvantages:1, isolated the generation of specific classes, so that users do not need to care about when the physical product was created2, when multiple objects of an abstract product (such as P8, P9, P10 in the Huawei P-series phones) are designed to achieve the same abstract product, the client can be guaranteed to use only the same productDisadvantages:1. It is difficult to expand the abstract factory when adding new products.Abstract Factory class: Entity
Design Patterns : Design Patterns are a set of reusable, most well-known, categorized purposes, code design experiences that use design patterns to reuse code, make code easier for othe
on request: Anyone who has used a servlet knows that, in addition to having a corresponding configuration in Web. xml, it is necessary to inherit an abstract class called httpservlet, and rewrite the Doget and Dopost methods (and, of course, just rewrite the service method).Many of the methods in the request object are used when the internal components interact with each other, such as setcomet, setrequestedsessionid, etc. (not listed here). These methods are not exposed externally, but must b
stamping dies, the concrete classes produced by the machinery can be changed within three minutes.
Check list
Decide if "platform independence" and creation services are the current source of pain.
Map out a matrix of "platforms" versus "products ".
Define a factory interface that consists of a factory method per product.
Define a factory derived class for each platform that encapsulates all references tonewOperator.
The client shoshould retire all referencesnew, And use the factory meth
Design the samples in Java.
Build Status:
Introduction
Design patterns are formalized best practices and programmer can use to solve common problems when designing a appli cation or system.
Design patterns can speed up the devel
Design patterns are specific solution patterns (routines) that can be reused for specific problems in a specific situation that is constantly emerging. According to the three categories of creation, structure and behavior, this paper summarizes the main points of use of 24 kinds of design
To correctly use state and policy patterns in Java applications, developers need to be aware of the differences between the two patterns. Although the structure of the state and policy patterns is very similar, they also follow the open and closed principle, representing the solid
iteration is obtained, the client begins the iterative process and prints out all the aggregation elements.Iterative sub-pattern benefits
Iterative sub-patterns simplify the aggregation of interfaces. The iteration has a traversal interface so that the clustered interface does not have to traverse the interface.
Each clustered object can have one or more iteration sub-objects, and the iteration state of each iteration can be independent
used.Two main uses of design patterns in software development.A common platform for developersDesign patterns provide a standard terminology system and are specific to specific scenarios. For example, a singleton design pattern means using a single object so that all developers who are familiar with the singleton
Java design patterns cainiao series (I) Modeling and implementation of policy patterns
Reprinted please indicate the source: http://blog.csdn.net/lhy_ycu/article/details/39721563
Let's start to talk about Java design
end, that is, the first to gain control over the added. As mentioned in this blog post, whether or not to add seasoning is a hook function, it has the discretion to add seasoning.If you specify a thread that is defined, it is a thread-specific hook, or a global hook if NULL is specified. Where the global hook function must be included in the DLL (dynamic-link library), the thread-specific hooks can also be included in the executable file. The hook function that gets control after processing the
of the current object */
Bytearrayoutputstream BOS = new Bytearrayoutputstream ();
ObjectOutputStream oos = new ObjectOutputStream (BOS);
Oos.writeobject (this);
/* read out the new object generated by the binary stream */
Bytearrayinputstream bis = new Bytearrayinputstream (Bos.tobytearray ());
ObjectInputStream ois = new ObjectInputStream (bis);
return Ois.readobject ();
}
Public String getString () {
return string;
}
public void SetString (string string) {
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.