Valueobject Introduction (VO mode)

Source: Internet
Author: User

I've been in touch with the AS3-based flex framework for the last few days. The Valueobject object (VO) is used to introduce this stuff ~ ~

Simply put, the value of the Valueobject (state) will not change once it is created . So it can be used as a basic data type . such as the string in Java , BigDecimal, BigInteger are valueobject. StringBuffer is not.

VO is a dto, is a design pattern , mainly used to reduce the number of data transfer , commonly used in the EJB, now the Struts project also advocates the use of this design pattern , DAO is a kind of access database Design Patterns , the idea is to encapsulate a database (and a data table) operations into a class , by other classes to call the class Method to complete the operation of the database, which simplifies the complexity and coupling of the classes responsible for business processing

DTOs are a layer between the Web layer and the EJB layer, and the data Transfer object factory is generally used to meet the design requirements of this model. DTO Factory is the only place where the DTO logic associated with a specific use case resides, and it helps to separate the client from the domain model .

A DTO is an abbreviation for data Transfer object.

DTO mode or VO mode refers to the encapsulation of data into a common JavaBeans, which is transmitted between multiple layers of the Java EE.

A dto resembles a messenger and is a message in a synchronization system.

The JavaBeans can be a data model.

The common way is to create a model class for the entity object that contains only getter and setterfor all fields of the object. For example, if a user entity has a name, password field, a Usermodel class is established, and the public method has getname,setname,getpassword,setpassword. This allows the UserForm to be passed as a parameter to other functions.

The Data Transfer Object (DTO) pattern is designed to solve problems such as one of our entity beans, which has a very good number of fields for the corresponding database table, and we are in the create method of its home interface and the parameters in the Ejbcreate method of the Enterprise Bean class are likely to be many, resulting in our methods not being elegant. We can define a simple Java class (implementing the Serializable Interface), which defines some properties and provides the appropriate get and set methods to solve the above problem.

uses Valueobject to encapsulate business data , and there is a separate method that can be used to get or send this VO , When the client requests some business data, the server can produce a VO and assign it a value, and finally, it can be passed to the client by using the Pass value method. The benefit of
is to reduce network conversations and accelerate data exchange between tiers , and I think that the greater benefit is making the program logic clearer and more
Object-oriented . When you write VO , implement the Serializable interface.
Public Uservo implements Serializable {
     private String loginId;
      Private String password;
     private String name;
     private String role;
     ...
}

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.