您的位置:首页 > 编程语言 > Java开发

JavaBean, POJO, VO, DTO, DAO 异同

2016-05-26 17:12 330 查看
refs:
https://dzone.com/articles/database-interaction-dao-and http://java-base.com/javabean-vs-dto-vs-pojo-jknb/

Plain Old Java Object (POJO)

The name is used to emphasize that a given object is an ordinary Java Object, not a special object. It has absolutly no restrictions.

POJO, or Plain Old Java Object, is a normal Java object class (that is, not a JavaBean,
EntityBean etc.)  and does not serve any other special role nor does it implement any special interfaces of any of the Java frameworks. This term was coined by Martin Fowler, Rebbecca Parsons and Josh MacKenzie who believed that by creating the acronym POJO,
such objects would have a “fancy name”, thereby convincing people that they were worthy of use.


JavaBean

JavaBean is a simple java class or POJO, but with some restrictions. This is the main difference between a POJO and a JavaBean. Some of the restrictions are:

JavaBean should provide default public constructor.
JavaBean should provide property accessor methods (getters and setters).
JavaBean should be serializable.
JavaBean is a example of POJO that is serializable, has a no-argument constructor, and allows access to properties using getter and setter methods that follow a simple naming convention.

Value Object (VO)

Value Object is simple object that holds values. The VO should be entirely
immutable
.

Data Transfer Object (DTO)

DTO is serializable object, which is used for transfering data between different processes. It shouldn’t be mixed with VO. This is exposed as design pattern.

Data Access Object (DAO)

This is an object, which provides mechanism for accessing objects from the persistance layer. This is actually one of the most popular design patterns.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: