This paper mainly introduces a design pattern of database-related classes. It also introduces the concrete implementation in the Java EE Framework and some considerations in the transaction processing.
Introduction of Design pattern
When developing a Java EE application, it is often necessary to find the various info
array when referencing tire.5. Synthetic relationship (composition) Note that the solid Diamond + solid Line (arrow) is used to connectThe synthesis relationship is stronger than the aggregation relationship, is a strong ownership relationship, embodies the strict relationship between the whole and the part, it requires that the general aggregation relationship represents the whole object is responsible for representing the life cycle of the part of the object, or their life cycle.class bird{
. Td ();}}Static and static methods are called first, and then the construction methodPackage com.fanshe;public class TestA {private static TestA Singleton = null;int x;Public TestA () {x = 15;System.out.println ("Enter construction method ...");}public static TestA Getsingleton () {System.out.println ("Singleton =" +singleton);if (Singleton = = null) {System.out.println ("into a single case ...");Singleton = new TestA ();}return Singleton;}public voi
The Java IO class expands using the adorner pattern, where the FilterInputStream class is the base class for the adorner (decorator).
To implement other adorners (decorator), you need to inherit the FilterInputStream class.
Code
the adapter pattern in Java design mode.
/** @author I set the date for J Mad 2007-4-18**/Package net.blogjava.lzqdiy;
Import java.util.ArrayList;Import java.util.Enumeration;Import Java.util.Iterator;Import java.util.List;
Public class Newenumeration implements enumeration{
Iterator it;Public Newenumeration (iterator it){This.it=it;TODO auto-generated Const
[number]; fori0ii{ threads[i] = new TestThread(hashSet, true, 200); } fori0ii{ threads[i].start(); } However, the results are not clear, and in some cases, the results are printed as follows:
22222222222222
The instant sadness, originally thought discovers the New world, the result, hey! Do not forget, what is the problem? Why would there be two singleton?OK, modify the test method:HashsetNewHashsetintNumber = -; testthread[] Thre
Template Methodology Design pattern (Templete method)Defines an algorithm skeleton in an operation, and delays the implementation of some mutable parts into subclasses.The template method design pattern allows subclasses to redefine some specific steps of the algorithm without altering the structure of an algorithm.1 ImportJava.util.Random;2 3 Public classAbstractTest002 {4 Public Static voidMain (str
The Observer pattern I understand is that when we trigger an event, we want to tell the action to the object I want to tell, and let them all do it, just to bind them to this event.
1. Define a base class (for adding observers also is the object I want to notify, as well as notifying the observer)
eventgenerator.php
!--? php abstract class
Template Method pattern (JAVA) of software design pattern, design pattern java
What is the template method mode?
Defines the skeleton of an algorithm in an operation and delays these steps to the subclass. The template method allows the subclass to redefine certain steps of
(); Buildinputpart (); } } /// ///Assembling HP Computers/// Public classAssemblehpcomputer:assemblecomputer { Public Override voidBuildmainframepart () {Console.WriteLine ("assembling the motherboard for your HP PC"); } Public Override voidBuildscreenpart () {Console.WriteLine ("assembling the display of an HP computer"); } Public Override voidBuildinputpart () {Console.WriteLine ("assembling the keyboard and mouse of the HP computer"); } } /// /
Java design pattern-policy pattern, java design pattern --
The rule mode is the behavior mode of the object. It is intended to encapsulate an algorithm into an independent class with a common interface for mutual replacement. The
Java Design Pattern -- factory pattern, java design pattern --The so-called factory is to build products, such as a small brick factory, there is only one kiln, both bricks and tiles can be made, this is called a simple factory model. The scale is a little bigger. I have mul
Analysis of JAVA Design Pattern Singleton pattern (1), analysis of java Design Pattern1 Overview of Singleton Mode
The Singleton mode ensures that a class has only one instance and instantiates the instance and provides the instance to the entire system.
The Singleton mode h
Java Design Pattern template method pattern, java Design Pattern TemplateTemplate Method Mode
Defines the skeleton of an algorithm in an operation, and delays some steps to the subclass. The template method allows the subclass to redefine certain steps of an algorithm withou
Java design pattern: appearance pattern; java Design Pattern appearance
I. Introduction
The appearance mode (Facade) hides the details and complexity of internal subsystems and provides the client with the same Calling Interface, making the complex system easy to access and
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.