MVC system architecture based on struts1.02
Yang Hengxian (yanghx@70345.com)
1. The importance of system architecture
The system architecture at the beginning of a project determines the success or failure of a project. "Good system architecture is equal to half of success." Good system design satisfied with maintenance, which is conducive to transaction processing during the development process. To do a good job in the system architecture, you have to pass the test. The following aspects must be made.
l Proficiency in designing design mode and can be used flexibly.
l The architecture design is a skeleton, and the design mode is meat.
l Design mode is an important component of the support architecture.
l Remember the goal of architecture design.
2. System architecture
The evaluation of the system architecture I summarize the following three principles:
l The maximum reusability of the main module
Generally speaking, more occasions related to the system-related main modules, generally using single mode design, in the design model, called Facade mode. Generally, more use interfaces can also be utilized.
However, in this architecture, I directly inherited the Action class, which inherited my class, which can provide unified Error and LOG processing in this system.
l The module related to system stability can perform transparent packaging.
The most important thing in this system is to deal with Database, in JDBC or data connection in the database connection pool is compared to system resources, so this piece is managed by our system. The RESULTSET provided in the JDBC will also install the system unstable. So these two pieces in this framework are processed by my underlying. In the future, it is no longer necessary to worry about these 2 pieces, so that the system can interact with the database.
In this framework, in order to support these 2, Factory Method and Builder in the design mode.
Two interfaces have been designed, and a database connection pool is designed to ensure efficiency. It is also necessary to further improve system performance for a business in this system, but this module does not return to test, so Not integrated.
l is simple enough for the system-related class libraries or functions
Everything is simple. A system is to make a system architecture for simplicity. If your architecture must have trouble, then this kind of thing can be thrown away.
The JBaseAction, JBasebusiness, JBaseDataBusiness, JBaseDataBean3 provided now, but this is in the base class, do not need you understand. There is no complex stuff in this way.
Here is a bad design, just starting to design JBasebusiness, there is no flexibility, the design is poor, and if it is correct, it can greatly improve the development efficiency.
3. Stringent test must be made every link
In my small frame, each unit must pass the regression test, I use JUnit. The code that has not been tested in a system is a performance of the stability of the system. We would rather not this unit. It must also be tested after integration.
Let's talk about this Struts1.02 framework, you want to fully understand this small frame, you must understand the Bridge mode.
Can adapt to different types of database operation database packages.
Features: 1. Adapt to different kinds of database operations
2, fully support JNDI-based database connection pool
Design ideas are as follows:
Fully follow the design mode of COM in the Windows system.
The UML map is as follows:
Let's talk about this package, we use mysql4 as an example, expand as follows:
Public class mysqldatabase extends commitb {private static string odbc_driver = "xxxxxxx";
Public mysqldatabase () throws exception {
}
Void init () throws exception {
Class.Forname (ODBC_DRIVER);
m_conn = drivermanager.getConnection ("JDBC: MySQL: // LocalHost / DB", "User", "Pass");
}
}
This way this database package can be used directly on the development of mysql as DB.
There is a shortcoming here without using the log4j record operation.
Let's introduce how to encapsulate CLOSE () with ResultSet in this system.
Completely transparent.
"Not complete"