One of the Reading Notes of struts2 technology insider

Source: Internet
Author: User

Chapter 2 fixed source retrieval ------ web development

2.1 three different object forms and Operation Modes

Attribute-behavior mode: an object has both property definitions and method definitions. Most objects work in this mode.

Attribute mode: indicates that an object only has attribute definitions and stores them in the corresponding setter and getter methods. The Java specification gives the objects in this mode a unified name: JavaBean. JavaBean can be used as the data storage mode and data transmission carrier.

Behavior mode
: Refers to the definition of a series of methods that constitute an object. Objects running in this mode are often called "stateless objects", which represent servlet objects.

2.1.1 attribute Object Mode

The attribute object mode is also called the JavaBean mode, such as Po (Persistent Object) --- persistence object, Bo (Business Object) --- business object, VO (Value Object) --- data transmission object, formbean --- Page Object, etc,These are only effective extensions or enhancements to the basic and running objects in the JavaBean mode.That is to say,The features of JavaBean are not changed, but some additional programming elements are introduced
. When an object operates in the attribute object mode, it is essentially the JavaBean feature of the object.

Conclusion: The production of JavaBean object mainly aims to emphasize the inherent characteristics and status of the object and construct a carrier for data storage and data transmission.

2.1.2 behavior Object Mode

Objects running in the behavior object mode are called stateless objects. The so-called stateless object actually means that the behavior characteristics expressed by the object method do not depend on the state of the object's internal properties.

Conclusion: The method definition in the object is a natural carrier for request response.

In the java standard, the response to HTTP requests is implemented through the servlet standard, and we know that the servlet object is a very typical stateless object running on the behavior mode.

2.2 object link model

Subordination-an object belongs to another object in terms of logical semantics.

Collaboration relationship-objects use collaboration to express a logical semantics.

2.2.1 subordination

There are two types of subordination: attribution and inheritance.

Conclusion: The attribution relationship exists in the object-oriented programming language in the form of mutual reference between objects. The inheritance relationship exists in the object-oriented programming language, it is mainly supported in the form of original ecological syntax.

2.2.2 collaboration

Conclusion: when the action of an object requires the action of another object, a cooperative relationship is formed between objects.

Software guru Martin Fowler once suggested that an object is not isolated in most cases, and it always needs to complete its own business logic through collaboration with other objects.

2.3 Basic concepts of Object-Oriented Programming

Conclusion: The composition model of each object has a specific range.

Conclusion: The object operates in the "Attribute-behavior" mode, which is most in line with the intention of object-oriented programming.

When an object operates in the "Attribute-behavior" mode, we can apply various design patterns to the maximum extent, and maximize the collaboration between objects.

2.4 essence of the framework

Conclusion: When we load a jar package to classpath, we actually get all the additional support for JDK in jar.

Our program is like a pyramid. At the bottom of the page is the JVM, which provides the basic environment for running Java programs, including compiling and running the entire Java program. Above this is the JDK, and then the jar layer. All the jar files loaded into the classpath are built on the JDK layer, which may form dependencies between them, they all provide functions other than JDK. At the top is our daily application.

Conclusion: The Framework is only a jar package, and its essence is to extend the functions of JDK.


Conclusion: The Framework is a set of programs and contains a series of best practices. It aims to solve the problems in other fields.


2.5 Best Practices

Best practices never stick to any best practices. The lock of truth will always be opened only for the most appropriate key.

Best practices always ensure program readability, maintainability, and scalability.

The best practice is simple.

Simple but readable, simple, but scalable.


Best practices use object-oriented perspectives for programming as much as possible.

Best practices reduce dependencies (eliminate coupling ).

The more jar you add to the classpath, the higher the program's dependence on the external environment. The higher the dependency on the external environment, the more difficult the program itself to perform unit tests from the specific external environment.

2.6 Basic Web development model-hierarchical development MVC model

Layer 3: Presentation layer, business layer, and persistent layer ).

Data Model --- Model

External interaction --- View

Program execution and control --- Control

Author: Mr. Lu Zhou.

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.