Design mode and J2EE technology

zhaozj2021-02-11  238

The article is not good, please give more opinions

Chapter 1 Design Mode and J2EE Technology

What is design pattern

Simply put, the mode is a real thing that appears in the world, and it is also a rule that tells you how to create an active, when you should create. It is both a process and a real thing; it is not a description of the current physical object and a description of the process of creating a physical product. --C.alexander, "The Eternal Road of Architecture" [I]

In software science, there are many kinds of patterns, some software management models, and practice proves to be different from traditional management, making a new model. Software analysis mode [CX1], there is software design mode [CX2], process mode [CX3], software reconstruction mode, etc.

What is the mode in software science? Can I completely borrow C.alexander defined mode? Some people say that the software is born with buildings, you have an embarrassment, and there is a number of minds. In fact, the GOF book already shows that in essence. However, the specific software field is different. It is a pity that because the software model theory has been in development, the recognized definition is not yet available. But there are several classic statements. It is said that the mode is a question in the situation that is confirmed by a program. This definition is relatively simple, concise. The mode in the book of Gang of Four is defined as three-segment value: indicating a specific situation, problem, and the relationship between the scheme. And in this way, the famous 23 modes (C language description) [CX4] are described in this way. The author of "J2EE Core Patterns" has also made a similar definition: mode is used to describe the problems exchanged and their solutions. And parsed 15 J2EE modes [CX7] with the introduction step [CX5] [A6] similar to the GOF book. [A8] Other books in the introduction mode, the papers also have its own mode definition. But all of the definitions in the GOF book and generally introduce it as a blueprint.

Understanding of the model

The mode in the software originated from the building [CX9], but as Gang of Four said in "Set [A10] Mold": Although Alexander refers to the city and architectural mode, his thoughts apply to object-oriented Design Patterns. Just in an object-oriented solution, we replace the walls and doors with objects and interfaces. The core of the two is to provide a solution for related issues.

In fact, we live in a model-filled world - of course, simple and affirmative premise is that our world is orderly. In addition to mad and metamorphosis, modern people are hard to wear clothes; most people eat three meals a day, and of course a day; in society, we belong to a community or group, participate in political, economic activities; In all activities we participate in, we must act in accordance with certain rules; people in the edge of the rules always want to join the ranks of the rules, just like our China has always adhered to the WTO. Eating, dressing, sleeping is our basic life requirements of our humanity; each of us must abide by, if a person does not dress, there is no other conclusion, he does not belong to humanity. Participating in the community, in a certain framework, social and economic activities are incorporated in human beings.

In fact, in the traditional Chinese tradition is more attention, such as Peking Opera, one trick has a set of routines; if the Chinese painting format pays attention to the routine, how to paint, there are several paintings; another kind of "Sun Tzu" - it can say already Become a general mode of "war" in all aspects, he tells you what array in any military environment, however, how to spell, you will rely on your own understanding and flexible application. Thus, the creation mode is the master of the master, but people who are in these models can only be called craftsmen. Of course, for the meaning of the mode, it is either integrated, or it is ignorant, they should first become a craftsman. Just as our China, at this stage, it is to actively participate in the development of the rules of the international community and economic activity, and use the traditional virtues and wisdom of the Chinese nation with the Chinese nationality, domestic social and economic communication methods, and then make it suitable for all humanity. Development of the Social and Economic Activity Rules. Why study and research design patterns

So why do we learn mode in software? What benefits have been brought to us, so many people are passionate? In fact, the truth is the same - we all need to learn from the master's experience, standing on the shoulders of the giant to better travel. Especially in the engineering field, this is more important. Secondly, learning models can take less to learn and develop software, so that our learning is strict from the beginning. The developed software can also be more SCALABLE and REUSABLE to provide stronger maintainability, shorter development life cycles. Know the pattern, the research mode can also make us develop more smooth, more modular, and reduce coupling. One term is to reduce internal stress, and the internal stress of rational discovery software can make the software system long. If the decomposition pressure in the architectural structure is generally, if the structure is unreasonable, the pressure decomposition is unexpected, the building is likely to be collapsed soon. Make new buildings / new software do not miss in a certain period of time is the basic reason we have to learn; can make our buildings / software long or even forever, it is moderate to attract our charm.

How to learn and study design patterns

It is also necessary to sprout the model development process from the building, let's take a look at the "three steps" professor of Christopher Alexander:

• Theory of research model - "The Eternal Road of Architecture"

• The first complete mode language - "Building Mode Language"

• Rational use mode to guide construction processes - "Oregon Experiment"

This article is to study the design model. The design pattern is first referred to by architecture designer Christopher Alexander in the A Pattern Language: Towns, Buildings, Construction (Oxford University Press, 1977). He introduced this concept and called the pattern - an abstract solution for repeated design issues - this concept attracts some of the attention of some researchers in other fields, especially in the late 1980s, those Develop object-oriented software personnel.

It is worth noting that research on software design patterns has created a letter to object-oriented books: Design Patterns: Elements of Reusable Object-Oriented Software (ie, "Design Mode", " Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides are incorporated. These authors are often referred to as the "Gang of Four", and many people also joked "four-person help", and this book is called "Four Group / Gang (or GOF)" book.

Under this classic mode theory, you can peek the essential importance. The usual step should be: First of all, we must understand the design mode. Everyone who is close to her will be called by her charm. This will transition to again: system learning design mode, after learning, and after learning, we must do it in the project. It must be pointed out that it is necessary to implement the specific environment when the final practice design mode is implemented, using a language, which is limited to a particular environment requires courage and change, and the paper talk is helpless. This article is an analysis and practice in the J2EE environment. J2EE and mode

J2EE technology

The research method of modern software is gradually popular, first, it will be seen from the so-called architecture. This kind of view is quite reasonable: from the whole, you can see it clearly, and you will be great, not only look far, but you can see it clear. It is not as good as a thing, it is not as good as J2EE, and there are those things inside, with the architectural map, you can have a look. The so-called view can be seen from the architecture, it is possible to compare from the system naturally with other technical systems. Where is the advantage of this system, where is the shortcomings, where the future direction should be; The so-called clear understanding, it means that the interlaced crowns between the various elements in a architecture, and the literary veins can be aerated at a glance. So whether it is a beginner, or a senior architect, they have a common feature that they like to see the architecture. J2EE is first organic as a whole. She is based on J2SE, including 13 main technologies [A11], see their structural map:

The overall structure of the J2EE platform can be seen, and most of his core technologies are also indicated: JDBC, EJB, RMI, JSP, Java Servlets, XML, JMS, JTS, JTA, Javamail and Jaf. In fact, J2EE is essentially composed of a set of services, applications interface (APIs), and protocols, providing functional support for developing Web-based multi-layer applications. J2EE also requires to describe when these technologies need to be used. Of course, how to interact between different technologies is to understand J2EE.

In the past, the two-layer application - commonly referred to as Client / Server applications - is the most talkative. In many cases, the only service provided by the server is the database service. In this solution, the client program is responsible for data access, implementing business logic, displaying results with appropriate style, popping up the preset user interface, accept user input, etc. The Client / Server structure is usually relatively easy to deploy, but it is difficult to upgrade or improve, and often based on some proprietary protocol - usually a database protocol. It makes it difficult to reuse business logic and interface logic. More importantly, in the web era, the second-floor apps usually cannot reflect good scalability, so it is difficult to adapt to the requirements of the Internet.

The part of the SUN design J2EE is to solve the defects of the secondary structure. Thus, J2EE defines a set of standards to simplify the development of N-layer enterprise applications. It defines a standardized component and provides a complete service for these components. J2EE also automatically handles many implementation details, such as security, multithreading, etc. for applications.

Developing N-layer applications with J2EE includes cutting different levels in the secondary structure into many layers. An N-layer application A can provide a separate layer for each of the following services:

Display: In a typical web application, the browser running on the client machine is responsible for implementing the user interface. Of course, the terminal type can be diverse [A12].

Representation: Although the browser can complete some dynamic content display, these dynamic generated work should be placed in the web server side, using JSP, SERVLETS, or XML (can be extended) Extended style sheet language). Business Layer: Business Logic Suitable for implementation with Session EJBS (later will be described later).

Data Access: Data Access is implemented with Entity EJBS (later later) and JDBC. Integration of the same system may need many different techniques, as the best needs to be based on the characteristics of the background system.

Why is there so many layers? In fact, multi-level approach enables enterprise-class applications with strong scalability, which allows each layer to focus on specific roles. For example, let the web server provide pages, apply the server to process the application logic, and the database server provides database services.

Since J2EE is based on the Java2 Platform Standard (J2SE), all of the advantages and functions of J2SE are available. Including "Write once, you can use" portability, access to the database through the JDBC, CORBA technology interacting with the original enterprise resources, and a validated security model. On this basis, J2EE adds support for EJB (Enterprise Java Components), Java Servlets, Java Server Page (JSPS), and XML technology.

With the introduction above, if it is not entangled in the implementation of the detail technology (so that there is a architect's discourse), the brain should have the following J2EE architectural map: All implementation J2EE specification Application Server must complete the full Web Container and EJB Container feature. There is a more detailed description of the selection and comparison of Application Server in [A13].

View J2EE Technology (Important)

After learning Java, I learned J2EE. The average person will have such a feeling: Getting started is easy, but it is difficult to further seem to be on the shelves, it is difficult. Where is the reason? In essence, there is no understanding J2EE. I don't know what he is reflected in him, just knowing that his part is necessary, but it is not enough. We need to use a new look to examine this peaceful technology, you can say this, in nature, J2EE is a model architecture, a framework software. Different from the Java language we have learned, we use the API when learning Java language, which is a toolbox. And J2EE, its application is defined in the beginning, the so-called Java Two Enterprise Edition, means that Java is used in corporate fields. Since the field is set, it can naturally define a set of architectures that are constant in this area. If it defines the JTA, JDBC and EJBs can be used to handle business requirements, a large number of database operational requirements. Enterprises generally use mail subscriptions, message processing, you can use J2EE technology to organically combine JMS, enterprise security requirements, J2EE provides system security solutions, which defines JaaS. In fact, various techniques are a whole and scalable, each J2EE application is assembled in accordance with their architecture. J2EE technology assembly. For example, a layer technology can be used as a JSP accessory. A non-typical use of WAP [II] can be used. No matter how they are J2EE face; the business layer technology can be EJB, non-typical can be servlet or even JSP These are the core technologies of business processing logic, often require high security; the resource layer connection is typically JDBC, non-typical use of JDBC-ODBC. As can be seen from the above, J2EE is designed with a frame structure-oriented technology - but this frame structure has extremely strong scalability and scalability. The frame structure means an implementation of ideas, and a large aspect J2EE is widely used in enterprise calculations, and it is believed that the portal that appears after 1998 has adopted J2EE technology. It is also an implementation of J2EE or MVC. In the above picture, the client gets the view, the intermediate layer is Controller, and the background is Model [III]. Therefore, in the case of enterprise applications, J2EE can take a different solution for situational applications (using a variety of kits). The unchanging thing has been defined, and the change is handed over to the programmer. Some people may think of .NET, in fact, she is also a frame structure, but it can be said to be "super (plagiarism) mode" application frame structure :-). Below we use the vision of the pattern to examine J2EE [A14]

The characteristics of the architecture (note is not every framework, J2EE flexibility has achieved maximum):

First, flexibility. Flexibility means that this structure or mode is not dependent on any actual application, and should be independent of the operating system and application. Provide an independent structure that provides maximum reuse.

Second, scalability. The development of new technologies is very fast. Imagine a application based on existing J2EE technology, if JDO [IV] is introduced into a specification, is this application based on "J2EE"? That is, J2EE's extension will not affect the problem of existing applications. Scalability application architecture does not affect existing applications. The hierarchical achievement of J2EE provides a smoothing transition of various technologies.

Again, scalable. For cluster applications, this functional requirement system has no bans. So far, in addition to the operating system-level cluster, it is probably that only J2EE can do this well in the application level.

Then, configurability. The application itself changes, because the demand will grow with the incompatibility of the personnel. This requires certain flexibility when configuring the application. For example, the access control of resources, only a few Web resources, can be provided to most people; with the expansion of the business, the new business is increasing, the business logic has increased naturally, and the control of this resource requires a flexible Mechanism to make a deployment. This flexible control can be provided in the XML file in J2EE. Finally, safety. Because the improvement in the network environment, the network application is explosive. A basic problem on the network is safe. A secure application should provide unified user access control to provide a single entry point. J2EE is born for the network environment. The front-end controller can achieve safety control in the J2EE mode.

J2EE design mode

Detailed infomation please ref: http://java.sun.com/boeprints/corej2eepatterns/patterns/index.html

Use mode in the project

One of the benefits of the model is to let you analyze from the system, understand your own and others, and get your opportunity in the design code.

In addition, the design of the model is designed to naturally appear many advantages: you can get inspiration of system design, design your own frameworks and even system, now there are many organizations and individuals to do this, such as Struts, etc. Homeway is similar to the organization. Make your own system more secure, flexible, maintainability - every point mentioned can develop more, better applications in a shorter life cycle.

Conversely, if you don't have a systematic mode idea, don't need to design the system, it is likely that you will hang a leakage when you design your own system, and there is a vulnerability. Below is an example of hanging a leaky:

[v] You can see this is an internal web page. He is an app based on J2EE technology, and the background server is a BEA WebLogic Server. According to safety, you should only visit users (rather than registered users more than any user) can access and use, otherwise spam or even other security issues. So there is a security control mechanism at each sub-page. The method of control is to add an authentication module to each page accessed, which ensures a simple session judgment every time the page is accessed. If you have the idea of ​​J2EE design patterns, it is not difficult to solve this problem: the front-end controller mode is a good choice. Unfortunately, any person who knows the absolute domain name can access this web page without reservation, and do some unsuccessful operations [VI] and these operations are unconstrained. [vii]

[i], leaded from "design mode"

[II], currently, J2EE-based WAP application development generally develops JSP and HTML first. The purpose of this is to debug relatively convenient

[iii], about the more detailed introduction of MVC, in the third chapter "MVC mode" section

[iv], JDO provides the ability to access the database, can replace the entity EJB

[V], if it is an electronic document, you can see the presentation, otherwise please read the text.

[vi], unspecified operations, unconstrained, people who have accessible will know that as a public welfare portal, still give him a little face.

[VII], more regrettable in almost a few months after the unsafe warning has been written, the site has not taken necessary protection actions.

website:

REF:

http://www.jdon.com

RET:

http://www.javaresearch.org

[CX1] Description Reuse Analysis Model, such as transaction, metrics, accounting and organization relationships. See "Analysis Patterns: Reusable Object Models" [CX2] is the most important mode. Usually object-oriented, description system design, component interaction, and specific language modes. It is the focus of this thesis.

[CX3] Description software process design.

[CX4] Netizen offers Delphi version, C # version, Java version

[CX5] Environment - Problem Domain - Role - Solution

[A6] What is the step?

[CX7] Mode directory is constantly evolving, discuss, stereotype, and release in Sun Java Center

[A8] There is corresponding description in this article, it should be connected to

[CX9] Dr. Yan Hong expressed different views in "Java and Mode" book. H: / & _ graduation design / pattern foundation / mode reference (Net) / www.javaresearch.org/Article/showArticle.jsp-column=31&thread=3572.htm

[A10] Find out the original text, make a reference

[A11] make a footnote

[A12] Can be found: That item 9CBS is introduced to the article of the terminal device

[A13] Make a connection when integrated into an article

[A14] Graphics need numbers

转载请注明原文地址:https://www.9cbs.com/read-3734.html

New Post(0)