Fake Objects
来源:互联网 发布:西门子s7一200编程视频 编辑:程序博客网 时间:2024/06/10 04:54
Spring的创始人Rod Johnson关于伪对象:
Fake Objects: objects in appearance, but which don’t exhibit some of the characteristics of objects:identity, state, and behavior。
Let’s look at some common fake objects and why to avoid them if possible:
❑ Transfer objects, often referred to as Data Transfer Objects (DTOs) or Value Objects. Transfer
objects are not true objects because they contain only state, without behavior. Transfer objects
are a necessary evil in distributed applications (although there’s an argument that this kind of
data should really be included in an XML structure rather than Java objects). But if we don’t
want a distributed architecture, they’re redundant and harmful, creating an unwelcome
impedance mismatch between business services and callers.
❑ Entity beans or other persistent objects generated from RDBMS tables. These reflect a relational,
rather than OO, model. They have a harmful effect on code that works with them, which
is forced to navigate relationships and cannot benefit from OO concepts such as polymorphism.
There’s also inadequate decoupling between business logic and persistent data representation.
❑ Persistent objects in general that contain only getters and setters, without behavior. Such fake
objects force behavior that they should encapsulate to be moved into control classes such as session
beans. Not only is encapsulation violated, but the result tends to be verbose code in control
classes.
UI+BLL+DAL+Model 是当前最常用的企业级开发的三层架构。但通常BLL层弱化为控制部分,即业务对象只有行为无状态,而Model层弱化为数据库的持久化表示,即只有状态而无行为。DAL变为BLL和DB的中介,而媒介就是Model。
如何由伪对象过度到真正的OO? 创建真正的BO,即有行为又有状态,这样就取消了Model层。
- Fake Objects
- Fake Glasses
- fake email
- fake wifi
- Fake Numbers
- Avoid Fake Jordan Shoes
- Remove Yootube.com Fake
- fake power balance freeshipping
- fake power balance freeshipping
- buy fake power balance
- BOJ 170 Fake Coins
- Installing with Fake RAID
- zoj 1514 Fake Tickets
- zoj1514--------------------------Fake Tickets
- ZOJ 1514 Fake Tickets
- HOJ 2519 Fake coin
- Hoj 2519 Fake coin
- zoj 1514 Fake Tickets
- windows 用户登录和注销监控|windows session 状态改变监控
- IOS indexPathsForVisibleItems原理
- Java读取Properties文件的七种方法
- tomcat端口配置文件解析
- 用DeflateStream和GZipStream压缩数据
- Fake Objects
- Java 八种排序算法比较实践
- linux进程通信--消息队列
- 目诊知识2
- 二叉树的基础知识
- 2016第七届美国新泽西国际武术锦标赛五月底在大西洋城开赛
- Oracle SQL日期比较
- java 初始化
- linux80端口启动访问项目