Java EE/J2EE object-oriented Programming Path

Source: Internet
Author: User

Oo Thinking

Often see a lot of people complain about the configuration of Java ee/j2ee too complex, cumbersome, not easy to learn, in fact, the so-called simple and easy to learn depends on whether you have OO thinking mode.

Presentation layer interface form is usually some discrete data, that is, a single field data, through struts and other frameworks to provide actionform and tag library, these individual field data encapsulation and business layer of domain model mapping, so The main programming work of the presentation layer is mapping configuration.

Persistence layer is to save the domain model object to the database, in the past using JDBC, we want to open each of these model objects, and then each field is saved to the database, if the presentation layer framework is to achieve discrete data encapsulation, then the persistence layer to achieve the opposite direction: unpacking. Hibernate is a persistent layer O/R mapping framework, the framework for mapping between objects and relational databases, and the CMP of EJBS is similar, so the main programming work of the persistence layer is also mapping configuration.

Presentation layer and persistence layer This configuration work is like packing a mailing: you first have to wrap your single piece in a box to reach your destination, the box is opened and a single piece is gradually removed. The presentation layer and the persistence layer are designed to ensure that the intermediate business layer is fully object-oriented, and that they are all dealing with objects, rather than single piece data fields.

In a truly object-oriented system, the primary task of the presentation and persistence layers is to configure and to map mapping configurations. The following question is: How to solve the mapping configuration is simple and easy to use, if you have the right guidance configuration of thinking, then the configuration of the work is easier, otherwise, feel more complex configuration.

In fact, those who feel the complexity of Java configuration in fact, he does not have a complete oo thinking. Why do you say that? An ORM (Hibernate) configuration is a simple way to explain:

The brief way of configuration

First, the configuration is the mapping configuration, as the name suggests, that is, in between the two to do coordination, matchmaking, frankly speaking, is to do matchmaker, but and do matchmaker and some differences, do matchmaker can require both sides to make some changes, mutual accommodation, but do mapping configuration, you can not do so, because it can make and requirements are not the same thing.

In the case of a persistent layer mapping configuration: both refer to the domain model object and relational data table, if it is difficult to configure the mapping between the two sides to make some changes, but there is a possibility that the demand does not agree, once you change for the coordination of the changes may deviate from the requirements of the realization of the goal, the final system to make a completely is not what the customer needs at all.

So what do we do? Clearly, the need to close the demand, reflecting the needs of the party firmly do not change, then domain Model and relational data table which side reflects the needs? According to OO analysis, of course, the domain Model,model object we are based on Evans Model-driven design MDD concept design, they are the representative of demand.

Obviously, our mapping configuration must follow the model object this thinking to match, for the nominal model, the association has nothing to do with its main relationship, of course, and inheritance, therefore, like hibernate these mapping configuration syntax is also oriented to these main object relationship.

Performance layer configuration is the same reason, need to configure the Domain model interface form, in practice, we may take is through the interface to collect demand, therefore, this mapping configuration process is to test whether the model object is extracted correctly or not, It is possible to find that the model does not implement some interface requirements, which in turn must modify our model, instead of just doing some remedial action on the technical level of the presentation layer.

The agile iterations of the Java EE/J2EE system development process are inevitable. No genius can one-step a unified model that takes into account the interface and data tables and requirements.

In short, to complete a truly object-oriented Java EE/J2EE system, you must grasp the domain modeling and specific framework skilled configuration two points, only in order to ensure the successful implementation of the Java project. The most critical is to extract the business system reflects the domain model: domain models, the completion of business modeling, is dependent on struts/hibernate and other configuration allocation model map to the interface and database, in fact, is the business model to the computer domain and can be correctly run.

Related Article

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.