Home IT Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Java Builder mode     - Solve ORA-01012: not logged on (Database)

- MySQL partition table Comments (Database)

- Linux, security encryption to transfer files between machines (Linux)

- Linux common network tools: traceroute routing of scanned (Linux)

- How to make Linux a non-root user uses less than 1024 ports (Linux)

- Linux how to handle file names that contain spaces and special characters (Linux)

- [SHELL] MySQL primary recovery solution from + Keepalived online (Server)

- Apache Web Security Linux systems (Linux)

- MySQL separation Amoeba achieve literacy (Database)

- CentOS install Java 1.8 (Linux)

- CentOS 5.5 kernel upgrade installation iftop (Linux)

- Linux Basics Tutorial: Linux Kickstart automated installation (Linux)

- The security configuration of Linux (Linux)

- Under CentOS Linux automatic backup MySQL database daily (Database)

- Oracle archive log size than the size of the online journal of the much smaller (Database)

- How to override the plain text files and directories soft connection in linux (Linux)

- Build Docker based MongoDB replication cluster environment (Database)

- Use SecureCRT to transfer files between Linux and Windows (Linux)

- Oracle Sql Loader tool has shown signs (Database)

- Linux 4.0+ kernel support for hardware switching module (HW Switch Offload) (Linux)

 
         
  Java Builder mode
     
  Add Date : 2017-08-31      
         
       
         
  Builder schema definition: The construction of a complex object with its representation of separation, making the same building process can create a different representation.

The Builder pattern is a step-by-step process of creating a complex object that allows the user to build them by specifying only the type and content of the complex object. Users do not know the specific details of the internal building. Builder mode is very similar to the abstract factory pattern, the slight difference probably only in the repeated use can be realized.

Why Builders

Is to decouple the process of building a complex object from its components. Note: The decoupling process and components.

Because a complex object, not only has a lot of components, such as cars, there are many components: wheels, steering wheel, engine, and a variety of small parts, etc., many parts, but far more than these, how these components assembled into a Car, the assembly process is also very complex (requires a good assembly technology), Builder mode is to separate parts and assembly process.

How to use builder mode

First, assume that a complex object is composed of multiple components, Builder model is the creation of complex objects and components were created separately, respectively, with the Builder class and Director class to represent.

First, you need an interface that defines how to create individual parts of a complex object:

Public interface Builder {
// Create part A for example to create a car wheel
Void buildPartA ();
// Create part B for example to create a car steering wheel
Void buildPartB ();
// Create part C for example to create a car engine
Void buildPartC ();
/ / Back to the final assembly of finished products (return to the final assembly of a good car)
/ / Assembly of the finished product is not here, but transferred to the following Director class.
// Decoupled processes and components are implemented
Product getResult ();
}}
With the Director to build the final complex objects, and in the above Builder interface is how to create a package components (complex objects are composed of these components), that is, Director's content is how the components assembled into the final product:

Public class Director {
Private Builder builder;
Public Director (Builder builder) {
This.builder = builder;
}}
/ / Part will be part of the final partA partB partC complex objects
// Here is the process of assembling the wheel steering wheel and the engine into a car
Public void construct () {
Builder.buildPartA ();
Builder.buildPartB ();
Builder.buildPartC ();
}}
}}
Builder concrete concreteBuilder:

Through the specific interface Builder to complete the assembly or assembly of the product components;
Define and define what it is to create concrete things;
Provides an interface to retrieve the product.
Public class ConcreteBuilder implements Builder {
Part partA, partB, partC;
Public void buildPartA () {
/ / Here is how to build partA specific code
};
Public void buildPartB () {
/ / Here is how to build the specific partB of the code
};
Public void buildPartC () {
/ / Here is how to build the specific partB of the code
};
Public Product getResult () {
/ / Return to the final assembly of finished products
};
}}
Complex Object: Product Product:

    Public interface Product {}
Components of complex objects:

    Public interface Part {
Let's see how to call the Builder pattern:

ConcreteBuilder builder = new ConcreteBuilder ();
Director director = new Director (builder);
Director.construct ();
Product product = builder.getResult ();
Application of Builder Mode

In the actual use of Java, we often use the "pool" (Pool) concept, when the resource provider can not provide adequate resources, and these resources need to be repeatedly shared by many users, you need to use the pool.

"Pool" is actually a memory, when the pool has some complex resources "broken limbs" (such as database connection pool, and sometimes a connection will be interrupted), if the recycling of these "broken limbs" will improve memory use Efficiency, improve the performance of the pool. Modify the Builder class in the Director class to enable it to diagnose which part of the broken limb it is on, and then repair the component.
     
         
       
         
  More:      
 
- Ubuntu 14.04 Boot Repair (Linux)
- Examples of Python any parameters (Programming)
- To install and use the Doxygen under Linux (Linux)
- Android recyclerview cardview (Programming)
- phpinfo (): like phpinfo as a Python script (Programming)
- Oracle Database Restore (Database)
- Realization of Linux operating system illegal IP censorship (Linux)
- MySQL Tutorial: About checkpoint mechanism (Database)
- Introduction to thread pooling and simple implementation (Programming)
- Ubuntu upgrade to Linux Kernel 4.2.3 Kernel (Linux)
- Depth study and understanding for individual users suicide DDoS attacks (Linux)
- Shell Programming Regular Expressions (Programming)
- How to Debian Linux the default Python version switch to alternative version (Linux)
- Smack 4.1.x Upgrade Guide (Linux)
- Zend Studio PHP syntax color scheme to export (Linux)
- Install NetBeans IDE 8.0 on Ubuntu, Linux Mint, Elementary OS, and Debian (Linux)
- CentOS / Linux SELinux Close (Linux)
- How to add a new hard disk without restarting the CentOS 7 / RHEL 7 virtual machine (Linux)
- Empty password Linux operating system (Linux)
- Oracle 10g after the failure to start the upgrade (Oracle instance terminated. Disconnection forced) (Database)
     
           
     
  CopyRight 2002-2016 newfreesoft.com, All Rights Reserved.