POJO

来源:互联网 发布:java jsonarray 添加 编辑:程序博客网 时间:2024/04/30 23:21

POJO和JavaBean的概念一直困扰着我。今天想把它彻底的搞一下下 :)

简单的Java对象(Plain Old Java Objects)实际就是普通JavaBeans,使用POJO名称是为了和EJB混淆起来, 而且简称比较直接. 其中有一些属性及其getter setter方法的类,有时可以作为value object或dto(Data Transform Object)来使用.当然,如果你有一个简单的运算属性也是可以的,但不允许有业务方法,也不能携带有connection之类的方法。

============================================================================

Plain Old Java Object. This acronym is similar to POTS — Plain Old Telephone Service.

“I've come to the conclusion that people forget about regular Java objects because they haven't got a fancy name - so while preparing for a talk Rebecca Parsons, Josh Mackenzie and I gave them one: POJO (Plain Old Java Object). A POJO domain model is easier to put together, quick to build, can run and test outside of an EJB container, and isn't dependent on EJB (maybe that's why EJB vendors don't encourage you to use them.)”
~ Martin Fowler

译文

POJO - 简单老Java对象 . 这个缩写看起来很像POTS - 简单老电话服务。

对于人们经常忘记常规的Java对象,我的总结是它们没有一个好名字 - 因此在准备一次演讲时,Rebecca Parsons, Josh Mackenzie 和我给起了名字: POJO。   一个POJO模型是易组合、快速建立并且运行于EJB容器之外的,不依赖于EJB的一类对象(这或许也是EJB提供商们不鼓励我们使用他们的原因)

原创粉丝点击