A review of Java design patterns

Source: Internet
Author: User

Since the advent of Java-EE, it has greatly simplified the enterprise-level development under the java-based. But as Java EE becomes more and more widely used in various fields, developers are becoming aware of the need for a way to standardize the application's development process by standardizing the architectural layers of the application. The structure layer typically encapsulates complex techniques that are independent of the business logic to establish a weak connection between the business logic and the underlying architecture. Some design patterns will be introduced in a topic that enables developers to standardize and simplify the application development process by leveraging these design patterns.

Application Architecture and Java EE

Java EE is a very successful technology that provides a consistent standard for some basic tasks, such as database connectivity, distributed applications, and so on. However, using Java EE does not guarantee that developers will develop successful applications. Some people think that Java-EE is a framework technology in itself, but this is not true, we should realize that the Java EE does not provide a framework to help developers develop high-quality applications, so many experienced developers through the use of design patterns to make up for this missing item.

Design Patterns

In the developer's circle, you enrich the experience of the entire circle by interacting with each other in the development process of problems and solutions. And the design pattern is created in such a case. A design pattern is necessarily directed at a particular problem, the solution to the problem, and the consequences of such a solution. In the process of solving the problems arising from the application of Java EE, people divide the design pattern into two kinds, one is the general development mode, the other is to solve the specific problem of Java EE. Let's look at what each type of development model contains.

Java EE design mode

The Java EE design pattern has evolved over the past few years with the growing experience of the developer. These design patterns are designed to address the problems that may arise when using various Java EE technologies, and they can help developers build the requirements of the application framework. For example, the Front Controller (front-end control) pattern translates the development of servlet code into development under a graphical user interface. But remember that the Java EE Design model solves the problems that are most likely to arise in the Java EE project. If you are experiencing a special problem in Java EE, it is likely that there is no corresponding design model to solve it.

Software Development Design Pattern

The software development design pattern is divided into two kinds, one is the universal object-oriented design pattern. For example, a factory (Factory) pattern is an object-oriented design pattern that encapsulates the creation of objects so that objects can be reused, reducing the amount of system resources that a program occupies. The other is a Java based design pattern that is either tightly coupled to the language features of Java or the Drill-down of object-oriented technology in Java. Don't assume that software design patterns are less important than the Java EE model, and they are usually more important than the Java EE design pattern. This is because:

1 The design pattern of Java EE is only appearing in recent years, and it is changing, and the software development design pattern has been tested for a long time, which is more mature and perfect than the former one.

2 Some Java EE design patterns are based on some software development design patterns;

3 The Software development model provides a solid foundation for the Java EE design pattern. Its application will affect the stability and extensibility of the whole structure.

In practical application, design pattern is not a specific code. Design patterns are usually described in the design specification. The real challenge in applying the design pattern to the system is how to apply the ideas in the model to the system. These ideas must be applied to the right environment.

According to the design pattern of the problem solved, but also can be divided into the following several types:

Create type: The pattern of the creation type is the instance used to create the class. Unlike creating instances with new, however, these patterns provide a more flexible way in which a program can create a specific class based on a particular situation.

struct type: A pattern of struct types helps developers to combine simple objects into more complex structures later.

Behavior type: Patterns of behavior types help developers control communication between classes.

Create a pattern for a type

All patterns of creating types are related to how to effectively create instances of the class. In Java, if a developer wants to generate an instance of a class, the easiest way is to use the New keyword:

Myfoo = new Foo (); Generate an instance of Foo

This method can only generate a fixed class in the program. However, in many cases, the program needs to generate instances of different classes based on different situations, which requires abstracting the instance's build process into a special creation class that determines which kind of instance to generate at run time. This makes the program more flexible and versatile.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.