, deep replication copies all the objects referenced by the objects to be copied.
The following example shows how to implement the following prototype:
Import Java. io. bytearrayinputstream; import Java. io. bytearrayoutputstream; import Java. io. ioexception; import Java. io. objectinputstream; import
Reference from: https://blog.csdn.net/justloveyou_/article/details/55045638
The meaning of existence: object-oriented technology can solve some flexibility or scalability problems, but in many cases, it is necessary to increase the number of classes and objects in the system. When the number of objects is too large, the cost of running is too high, which brings about the performance degradation and so on. The pattern of the privilege was born to sol
Responsibility Chain Mode of JAVA design pattern; responsibility of java Design Pattern
What we bring to you today is the JAVA design pattern.Someone may ask: What is JAVA? What is the design
, developers must remember that they cannot instantiate objects using Newkeyword.Because you may not be able to access the library source code. As a result, application developers may accidentally find themselves unable to instantiate this class directly.3) Object lifetimeThe problem of deleting a single object cannot be resolved.In a language that provides memory management, such as a. NET framework-based language, only a singleton
In Dr Shanhong's "Java and Schema" book, this describes the visitor (Visitor) pattern:
The visitor pattern is the behavior pattern of the object. The purpose of the visitor pattern is to encapsulate actions that are applied to some data structure element. Once these operati
Observer mode:
The Observer Pattern Defines a one-to-define dependency between objects so that when one object changes state, all of its dependents are notified and updated automatically. (The Observer mode defines a one-to-many dependency between objects, so that every time an object changes its state, all objects dependent on it will be notified and automatically updated)
Subject (object interface observed)
Specifies the unified interface of concr
"Bird", "fish" is a decorative category. To decorate is "the Holy Buddha", also known as "Hozen" example.In the above example, the system decorated the holy Man from a hozen into a bird (the function of the birds added to the Hozen body), and then decorate the birds into a fish (the function of the fish added to the Hozen + birds, got Hozen + birds + fish). As shown, the change of the sage first attaches the function of the bird to the Hozen body, and then attaches the function of the fish to
addition to the classes that add new functionality. Adds complexity, and the factory method pattern puts the branch statements back into the client code, and it needs to modify the branch structure in the client to determine which class of factory to create. In the following blog post we will learn that this shortcoming can be solved by the reflection mechanism of Java
In the book "Java and Patterns" of Dr. Shanhong, this describes the template method pattern: The template method pattern is the behavior pattern of the class. Prepare an abstract class, implement some of the logic in the form of
Talking about the JAVA Design Pattern -- FactoryMethod and java factory patternReprinted please indicate the source: http://blog.csdn.net/l1028386804/article/details/45440937I. Overview
Defines an interface used to create objects, so that the subclass determines which class to instantiate. FactoryMethod delays the inst
Java Design Pattern principle and java Design Pattern Principle
1,Identify the potential changes in the application and separate them from those that do not need to be changed.
In other words, if every new requirement changes some code, you can determine that this part of code needs to be extracted to distinguish it
Memorandum mode of Java design pattern; Memorandum of java Design PatternThis article continues with the memorandum model of the 23 design patterns series.During programming, we often need to save the intermediate state of the object. When needed, we can restore to this state. For example, when we use Eclipse for programming, we want to return the status before t
Java Design Pattern learning, java Design Pattern
Proxy)
In fact, the name of each mode indicates the role of this mode. The proxy mode is to add one more proxy class to perform some operations for the original object. For example, we go back to the intermediary when renti
);
Subjectfor3d.setmsg ("20140420 of the 3D number is: 127");
Subjectfor3d.setmsg ("20140421 3D number is: 333");
}
Output results:
Observer1 get 3D number-->20140420 3D number is: 127, I want to write down.
Observer2 Get the 3D number-->20140420 3D number is: 127 I want to tell the roommate.
Observer1 get 3D number-->20140421 3D number is: 333, I want to write down.
Observer2 Get the 3D number-->20140421 3D number is: 333 I want to tell the roommate.
Definition: provides a way to access the elements of a container object without exposing the internal details of that object.Type: behavior class patternclass Diagram:
If you want to ask one of the most used patterns in Java, the answer is not a single pattern, not a factory pattern, not a policy model, but an itera
The source code is JDK1.8 as reference1. Definition:Defines the framework for an algorithm in an operation, and delays some steps into subclasses. Enables subclasses to redefine some specific steps of the algorithm without changing the mechanism of an algorithm.2. Analysis:General class Diagram:class Diagram parsing:The template method pattern is very simple and only uses the
Java design pattern (1) simple factory pattern is not simpleSimple factory Use Cases
There is an abstract product-Car, and there are a variety of specific sub-products, such as BenzCar, BMWCar, and LandRoverCar. The class diagram is as follows:
As a driver, if you want to drive one of them, such as BenzCar, the most di
Intent
The intent of a Null Object is to encapsulate the absence of an object by providing a substitutable alternative that offers suitable default do nothing behavior. In short, a design where "nothing will come of nothing"
Use the Null Object pattern when
An object requires a collaborator. The Null Object pattern does not introduce this collaboration-it makes use of a collaboration that already exists
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.