Performance layer control in accordance with OO conventions [Cao Xiaogang]

Source: Internet
Author: User
Tags define implement inheritance interface client
Control
Hibernate's Reference title is called: the Java-compliant O/R persistence, which reveals the major problem with the current three-tier structure, namely, the three-tier unification. So far, it is still difficult to implement the "Master-detail" and "lookup" user interaction in the C/S mode in the Web interface.

The current common Web application structure contains Web Browser/application server/database. Database occupies the mainstream is still the classic E/R model, which is based on the rowset, so in Vb/delphi/power builder practice, the data source/table set is based on the rowset, ODBC/JDBC Driver are also based on the rowset. The view layer's DBGrid is also based on the row set, and the entity model corresponds very well, the development is simple and intuitive, believed this is the C/s pattern obtains the rapid promotion one of the key reasons. "Master-detail" and "lookup" are the most common and intuitive correlation modes in C/S mode.

But in essence, Object Pascal/java are object-oriented. Here, there is a major inequality: OO vs E-R. The workaround is the EJB and O/R mapping tools. The entity bean of the EJB is the early Entity encapsulation form. However, compared to the present advanced tools (for Pojo execution persistence) represented by hibernate, it is cumbersome and difficult to use for OO and ER. Among these tools, the most essential function of the integration of OO and E-R is the corresponding relationship between the inheritance tree and the table structure. Hibernate2 supports an entire inheritance tree corresponding to a table, each class in the inheritance tree corresponds to the two basic correspondences of a table, and the join tag introduced by Hibernate 3 is more able to fuse the pair, implementing each class's optional to persist in the same table as the base class or save some persisted data in a new table. It can be said that Hibernate 3 the corresponding task accomplished very well. "Master-detail", "lookup" corresponds to "One-many", "Many-one" in a mapping file such as Hbm.xml.

After the fusion of database and Java is complete, the next step is inevitably the convergence of existing Web client and server-side code. On the surface, most web-client uses html/javascript, and server-side Java output, the two is a simple command/feedback model, the model developed from Model 1 to the MVC pattern, the code became clear, but developers still found that Writing web Apps is still not a simple thing to do. Struts/webwork is still just a very low-level base, and it doesn't help to write client business objects. For example, when a server-side Java program is modeled, everyone is accustomed to pojo the order/customer/product, but when writing Web clients, Struts/webwork can only help you complete the page submission/feedback process, but it does not help you analyze the client business: When you create a new order, After selecting the customer, determine if the customer has enough prefetching, such a simple use case in the minds of programmers is still the input tag for each field, each page post model, and how to use action to render the next page again.

The biggest problem is that the Web client-side code as a presentation layer is disconnected from the semantics contained in the server-side code. In particular, when adopting an MVC structure such as struts/webwork, it is generally not considered that business control is performed at the client, such as whether the javascipt is sufficient to determine the amount of the receivable. As a result, multiple page refreshes are required to complete the entire logic.

To work around this problem, you can usually move the business logic part to the client, JavaScript + XMLHTTP or JavaScript + Web Service,java applet/application, or even the Office platform ( Embed code into Excel) to complete the entire business logic. There are also many questions:

1, to implement the business logic on the client side, it is possible that the client code does not correspond to the underlying object facility such as Pojo. JavaScript lacks an infrastructure such as interface. Excel solutions are more difficult to do at this point, because the whole development involves too much language, resulting in more difficult to develop and project control. The immediate consequence is that it is difficult to define "Master-detail", "lookup", and so on in client code. Even if you define POJO (plain old JavaScript object) and its association in JavaScript in a project plan, it is difficult to use a ready-made association description such as Hbm.xml.

2, the client infrastructure is difficult to interface element binding. In the process of processing a large number of data, Excel solution in this embodiment of the outstanding advantage, the customer to the built-in program Excel acceptance is very high, but the disadvantage is that this Excel program is difficult to do XMLHTTP can easily do dynamic query and other characteristics.

3, the client infrastructure is difficult to interact with the server side. XMLHTTP and Web service are optional, but inefficiencies in enterprise applications can lead to potential server stress and reduce performance and throughput. Excel Solutions also face the challenge of interacting with server data. Both the XMLHTTP scheme and the application programme are faced with the requirement of abandoning Struts/webwork request/response dispatch.

4, the client infrastructure is difficult to unit test. There are junit4js,port of JUnit 3.8.1, but no mature stub/mock tools. Excel scenarios are almost impossible to test here.

5, the client infrastructure is difficult to debug. JavaScript lacks log tools such as log4j (Log4js http://www.petrusrex.com/Programmes/jslib.htm is far from mature) and is difficult to track with breakpoints. The Excel scenario has a complete VBA environment.

6, the client infrastructure operation efficiency is low. Javascipt/vba is a language of interpretation, it is difficult to implement complex logic, and its performance is determined only by using them for fine-grained interface control.

7, due to the fragmentation of the browser, resulting in language is not standard, the application is difficult to use across platforms. In the IE platform, behavior and expression can be used for AOP operations, but they cannot be implemented in Mozilla.

JSF scenarios are expected to be alternatives, but in the current case of myfaces, more complex and flexible controls can be achieved by implementing more performance-layer controls.

The following is a breakthrough in the way software development, look forward, there may be a breakthrough in design, MDA is the direction, the other direction is a breakthrough in concrete implementation, in similar webapp such as specific technology (in addition to webapp,application also face similar problems), There may be a new round of competition for JSF and. NET as to whether the definition of model can be brought directly into the presentation layer.


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.