Evolution of Javaweb Program architecture model

Source: Internet
Author: User

Evolution of Javaweb Program architecture model

Older programmers have generally experienced the evolution of the Web program architecture pattern, from the very beginning of the development of JSP or Jsp+servlet, to the later MVC, three layers and so on. And now a lot of people have learned the web, probably did not use JSP or Jsp+servlet developed projects, directly learn to use spring, Spring Boot or SPRINGMVC framework for development. Without such a gradual evolutionary process, it is difficult to understand what the framework brings to us, and it is difficult to solve problems in the development process, let alone learn the source code in these frameworks. Learning is a gradual process, not to be anxious, so this article is intended to simply chat about the history of the Web.

A brief history of Web development

With the current spring boot as the timeline, the Web development process can be broadly divided into the following stages:

1. Pure Jsp/jsp+servlet/jsp+javabean+servlet
2.MVC/MVP/three-tier architecture
3. The development of distributed applications using EJBS, EJB is a heavyweight framework that is more complex and cumbersome to use
4. Because the EJB is too heavy, so spring came into being, but spring is growing more and more bloated, so there are many cumbersome configuration
5. Similarly because the string configuration is too cumbersome, so spring boot was born, then you can experience the "Convention is greater than the configuration" fun

Second, the initial stage of web development

1.jsp/jsp+servlet/jsp+javabean+servlet Development Mode:

At the very beginning, JSP just came out, at that time the web development is basically done on the Jsp+javabean. More directly to the page, logic, data processing are all written on the JSP, want to know that this way to develop the project code is not only chaotic, and very high coupling, resulting in difficult to maintain the project.
The pure JSP flowchart is as follows:

The Jsp+javabean flowchart is as follows:

Believe that a lot of people at the beginning of learning javaweb, more or less have used the development of the above two models, the first mode is needless to say, all the code is written on the JSP on the coupling degree is quite high. Although the second mode is decoupled to some extent compared with the first one, the JSP is still responsible for the page control and the processing of the request and response, the responsibility is not single. The coupling degree is still relatively high, the result of high coupling is that the JSP code is very complicated and chaotic, and the maintenance is very difficult later.

Although the above model is relatively simple to develop, it is also suitable for small projects, but because of the confusion of code maintenance difficulties are gradually eliminated.

After the pain of this pattern has been added to the servlet, then JSP is only responsible for page control, servlet responsible for data validation, JavaBean responsible for the specific business logic and data processing, encapsulation and database interaction and so on.

The Jsp+javabean+servlet flowchart is as follows:

There has been a bit of MVC in this pattern, but this pattern is not yet known as a more sophisticated MVC design pattern. This pattern is more explicit than the previous two modes, extracting the servlet layer and embodying a simple layering idea.

Mind Mapping:

Third, the web development of junior level stage

1.MVC Architecture Mode
In this time, the MVC architecture pattern has been applied to web development, although MVC is not a new architectural model, and the MVC pattern has existed since the desktop development. MVC is the abbreviation of model, view, controller, and MVC breaks down the system into three parts, one is relative independent, the other is single, and can focus on its core logic in the realization process. MVC is a kind of rational carding and slicing of system complexity, its thought essence is "separation of concerns". As for the division of Duties and interrelationships of the MVC ternary, here is no longer to repeat, giving a very detailed explanation:

Illustrates the functions and relationships of MVC components.

The modes of communication between the parts of the MVC pattern are as follows:

View Transfer command to Controller
Controller needs Model to change state after completion of business logic
Model sends new data to View, user gets feedback
All communications are one-way

When you accept user directives, MVC can be divided into two different ways. One is through the View acceptance instructions, passed to the Controller, the flowchart is as follows:

The other is to accept the instructions directly through the controller, the flowchart is as follows:

Generally in the actual project is often used in a more flexible way, usually the two methods are combined, the approximate flowchart is as follows:

1. The user can send instructions to View (page request).
2. The user can also send instructions directly to the Controller (servlet request).

Now the SPRINGMVC is the framework of the MVC architecture pattern.

MVP Schema Mode:
MVP is like MVC, MVP is evolved from classic pattern MVC, their basic ideas have the same place: Controller/presenter is responsible for the processing of logic, model provides data, view is responsible for display. So a lot of people are not very clear the difference between the two models, in short, the main difference is that MVC is one-way communication, and MVP is two-way communication. MVP mode renamed Controller to Presenter, so at the same time changed the direction of communication, the flowchart is as follows:

MVP Features:

    • The communication between the parts is bidirectional.
    • View and Model do not contact, are passed through Presenter.
    • View is very thin and does not deploy any business logic, called "Passive View" (Passive view), without any initiative, and presenter is very thick, where most of the primary logic is deployed.

Three-tier architecture mode:
The three-tier architecture (3-tier architecture) typically has a three-tier architecture that divides the entire business application into: the interface layer (User Interface layer), the business logic layer, the data access layer Access layer). The purpose of distinguishing hierarchy is to think of "high cohesion and low coupling". In the design of software architecture, layered structure is the most common and most important structure. Microsoft's recommended layered structure is generally divided into three tiers, from bottom to top: The data access layer, the business logic layer (or also called the domain layer), the presentation layer.

Many people tend to confuse the three-layer pattern with the MVC pattern, and the most different of the three-layer and MVC lies in the concept of three-tier without controller controllers. Although the same architecture level, the three layer is the same as MVC is that they all have a presentation layer, but they are different in the other two layers. MVC does not consider the logical access of the business as two tiers, which is the main difference between a three-tier architecture or an MVC build program. Of course, the model concept is also mentioned in layer three, but the concept of model in the three-tier architecture is not the same as the concept of model in MVC, and the typical model layer in the "three layer" is made up of entity classes, while MVC is composed of business logic and access data.

In layer three, both the JSP and the servlet code belong to the presentation layer, the business logic layer is the entity class that completes the business rule, the data access layer is the code of JDBC, etc.:

The above has introduced several architectural patterns, you can see that the evolution of the architectural pattern is to understand the decoupling, low-coupling architecture to facilitate the maintenance and expansion of the project later, good architecture model can make the project better robustness.

Iv. advanced stage of web development

This phase begins the development of distributed applications using EJBS:

EJB is the Sun's Java EE server-side component model, and the design goal and core application is to deploy distributed applications. In simple terms, a program that has already been written (that is, a class) is packaged and placed on the server for execution. With the advantages of Java cross-platform, distributed systems deployed with EJB technology can be limited to specific platforms. EJB (Enterprise JavaBean) is part of the Java EE, which defines a standard for developing component-based enterprise multi-application applications. Features include network service support and core development tools (SDKs). In Java EE, Enterprise Java Beans (EJB) is called Java Business Bean, which is the core code of the kernel, namely the session bean, the entity bean Bean) and the message-driven bean (Messagedriven bean). After the launch of EJB3.0, entity beans were separately separated to form a new specification JPA.

EJB is technically not a "product", and EJB is a standard that describes the building of application components to be resolved:

    • Extensible (Scalable)
    • Distributed (distributed)
    • Transaction processing (transactional)
    • Data storage (persistent)
    • Security (Secure)

The above transfer from Baidu Encyclopedia.

Since I personally did not use the EJB development, do not dare to express their views, so as not to mislead everyone, interested in EJB can refer to the following articles:

Http://www.uml.org.cn/j2ee/2009112011.asp

The Birth of spring:
In his book, Rod Johnson's 2002-year-old book, "Expert One-to-one and development", has challenged the bloated, inefficient, and unrealistic academic practices of the Java EE Orthodox Framework (EJB). And with this book as the guiding ideology, wrote the INTERFACE21 framework, that is, later spring.

The spring framework, which is based on optimal methods and is suitable for a variety of application types, is attributed to Rod Johnson. These ideas are also described in his book. After publication, the source code is provided under the Open source Use agreement, based on the reader's requirements.

A group of program developers who volunteered to expand the spring framework formed a project on SourceForge in February 2003. After working on the spring framework for a year, the team released its first version (1.0) in March 2004. After this version, the spring framework became extremely popular in the Java community, partly due to its better documentation capabilities and references, especially for an open source project.

Spring solves the problem of loose coupling between the business logic layer and other layers, so it runs the interface-oriented programming concept throughout the system application. In short, spring is a layered, javase/eefull-stack (one-stop) lightweight, open-source framework.

Features of the Spring framework:

    • Light weight
    • Control reversal
    • Face Tangent
    • Container
    • Framework
    • Mvc

Spring Architecture Overview:

Although spring is a lot lighter than EJB, spring is a bit bloated and somewhat cumbersome to configure, but spring is still one of the mainstream frameworks now. The existence of the framework is to facilitate the use of some architectural patterns, no longer from the ground up to start development, improve the efficiency of development.

V. Current phase of web development

So far, there have been many good Java open-source frameworks, including spring, SPRINGMVC, spring boot, Struts, Hibernate, MyBatis, and so on, where spring boot is the simplification of the spring framework. Through these frameworks, we can efficiently apply architectural patterns to develop large-scale projects.

Simplified, Spring boot framework:

Spring Boot is a new framework provided by the pivotal team designed to simplify the initial setup and development of new spring applications. The framework uses a specific approach to configuration, which eliminates the need for developers to define boilerplate configurations. In this way, Spring boot is committed to becoming a leader in the burgeoning field of rapid application development (rapid application development).

Spring Boot Features:

    • You can create a standalone spring application
    • Embedded Tomcat without the need to deploy the war file
    • Simplify MAVEN Configuration
    • Automatically configure Spring
    • Provides production-ready features such as indicators, health checks and external configurations
    • Absolutely no code generation and no configuration XML required

Spring Boot Although the purpose is to simplify the spring, it seems to not need to learn the cumbersome spring configuration, direct learning of spring boot is good, simple configuration, but if not endure the cumbersome spring configuration, Without experiencing the evolution of architectural patterns and the Javaweb Foundation, the use of spring boot is prone to errors that have not been encountered and are not known how to solve them. And the design pattern is not familiar with, also do not know how people's framework is implemented, design ideas completely do not know, so even if there is a good frame in the hand can not play 6, let alone to design architecture mode.

Vi. Summary

From a brief history of the above, we can see how these mainstream frameworks are being used and why they should be. It can be said that our current learning technology to catch up with the best times, now there are so many excellent open source framework can be used, and so many design ideas can learn from, we skipped a lot of predecessors often tread on the pit, it is the predecessors stepped on these pits, in order to develop so many excellent open source framework and design ideas. But we should also go through the evolution of this architectural pattern in order to understand the benefits of different architectural patterns and frameworks. Now the new things more and more, you and I only keep improving, keep learning to keep up with the times.

Evolution of Javaweb Program architecture model

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.