Fake Objects

转载 2016年05月31日 11:11:36

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

UI+BLL+DAL+Model 是当前最常用的企业级开发的三层架构。但通常BLL层弱化为控制部分,即业务对象只有行为无状态,而Model层弱化为数据库的持久化表示,即只有状态而无行为。DAL变为BLL和DB的中介,而媒介就是Model。

如何由伪对象过度到真正的OO? 创建真正的BO,即有行为又有状态,这样就取消了Model层。



  • 2016-11-17 16:25
  • 510B
  • 下载

苹果团队App开发流程|Fake it till you make it

WWDC 2014 上,Apple的原型设计团队分享了公司内部的一套App开发流程。在完成App之前不断的进行原型迭代,这个过程中,原始的idea逐步变的更加具体真实,最终达到满意的用户体验和达到预期...


  • 2010-03-15 15:00
  • 126KB
  • 下载

CMDNotepad, a fake notepad

  • 2014-01-07 12:22
  • 51KB
  • 下载

Codeforces Round #411(A. Fake NP; B. 3-palindrome; C. Find Amir; D.Minimum number of steps)

A. Fake NP 题解:给定一个闭区间的两个端点,试判断在此区间内所有数字的非1公因子出现最多的数字。如果有多个,给出其中一个就可以了。这道题比较讨巧的方法试直接输出2。 B. 3-pal...

Fake browser

  • 2013-04-29 02:41
  • 4.01MB
  • 下载

Fake Ninja 2.7 by Spirit

  • 2007-06-21 17:36
  • 278KB
  • 下载

Fake API工具:interfake快速入门

1.interfake是什么? Interfake is a tool which allows developers of client-side applications of any pla...

UVALive 4957 Fake scoreboard 最大流

传送门 题意:给你行列的个数,然后给你每行Y的个数,每列Y的个数,看是否有符合条件的由NY构成的矩阵,有的话输出,要求字典序最小的那个。 思路:最大流问题,首先可以建立超级源点,将源点向代表行的点建立...