这个例子很老啦,在之前的Domain Model的争论中被广泛引用(参见:http://www.javaeye.com/topic/11712)。我再来炒炒冷饭。
这个Domain可以简化为这样:
public class Item {
private Set<Bid> bids = new HashSet<Bid>();
}
public class Bid {
private User bidder;
private int amount;
}
现在我们要添加一个行为叫placeBid。于是我们可以写出如下的贫血代码:
...
好老的话题啦。拿出来炒炒冷饭。各位见谅。
——————————————————————
Domain Model贫血是说属于Domain Model的逻辑没有放在Domain Model中。那是哪些逻辑没有放到Domain Model中,从而导致贫血一说呢?原因有很多,但是我认为最主要是Service中的那些逻辑。而这些逻辑又有一个共同的特点就是依赖于DAO,或者说需要查询数据库。Robbin的帖子:http://www.javaeye.com/topic/57075,举了一个很好的例子。我取其中的一个部分在这里做演示用。
public class Employee {
pri ...
Windows
Win32 API (pywinauto, autoit)
MS Accessbility (?)
UI Automation (eft, white)
In CLR object model (Sharprobo)
WEB
In browser DOM, Using frame (Selenium)
In browser DOM, Using proxy (Sahi)
Out browser DOM, Using specific browser pluggin (Watir)
Java
In JVM object model/java.awt.Robot (abbot) ...
Pain Point 1: XAML always create the controls by its default constructor
This means, you need to have a default constructor for you control, and the constructor will always be used by XAML. So, you can not use constructor dependency injection to pass things like services, gateways to your control. ...
Lesson 1: trust it
Everything could cause problem. There is no API could be really stable. Even it is stable itself, the interop and version difference or mis-use could cause problems as well.
Lesson 2: rely on 3rd party vendor
Add-in express is causing lots of troubles. Should be no feature rely ...
Outlook的对象模型中,很多对象都有一个MAPIOBJECT属性。这个属性可以用来获得对应的MAPI对象。最简单的应用可能就是取得MailItem上的一些额外属性,比如取得Attachment的ContentId。
要正确使用这个属性不容易。首先,不要在进程外取得属性的值,也就是说不能用Office Automation来启动Outlook,必须是在AddIn中取值。用伪代码,示例如下:
Marshal.GetIUnknownForObject(attachment.MAPIOBJECT)
Marshal.QueryInterface(pUnk, ref IID_IMAPIProp, ...
早上送女友去上班,从东直门到宣武门。因为反正要返回东直门的,所以索性坐了完整一圈。早八点的二号线,真是相当的恐怖啊。观察出了一个最高峰的地铁段,从复兴门到阜成门。也许大家都住在一号线沿线,然后去金融街上班吧。东直门的人反而不是很多。
汉语编程上CSDN首页了。不少骂傻逼的人,不少人说没搞头。我觉得,还是有搞头的。但是搞法,不是现在的这种搞法。不是用
如果(真)
替代
if (true)
这就没搞头,谁都知道输入中文慢,谁都知道大部分的API是英文的。这个层次太低!在实现这个层面,搞中文编程,没有多少实际意义。
提高层次是关键
if,else这个层面,是面对程序员的。作为一个程序员,你会用中文编程吗?需要中文的人,是那些懂业务不做编码的人。如果发明一种汉语编程语言来描述业务规则,而不是具体的实现,然后让懂业务的人去读,甚至让他们去写。说不定,还有搞头。
- 15:19
- 浏览 (377)
- 评论 (2)
someone told me, don't do that. Framework should free the com reference for you. but...
if you are writing a AddIn for PowerPoint, you might have seen the same problem. That is, if you reference a element of GroupItems without release it immediately, next time, you group it into bigger group, and t ...
- 22:46
- 浏览 (444)
- 评论 (0)
http://www.infoq.com/news/2007/10/next-gen-functional-testing
pretty easy:
UI automation testing is the key thing
Distributed running tests in Virtualized environment is critical
BA's lo-fi prototype should be testing script
BA's acceptance criteria should be testing script
QA's automation testing ...
- 09:45
- 浏览 (359)
- 评论 (0)
- 浏览: 76401 次
- 性别:

- 来自: 北京

- 详细资料
搜索本博客
我的相册
step2
共 6 张
共 6 张
最近加入圈子
最新评论
-
贫血的Domain Model ...
robbin 写道pig345 写道taowen 写道 连接的获取和释放,和事务 ...
-- by pig345 -
贫血的Domain Model ...
从简单设计和重构的角度来看。最开始,应该是直接在action中调用domain。 ...
-- by taowen -
贫血的Domain Model ...
pig345 写道taowen 写道 连接的获取和释放,和事务的管理是Servi ...
-- by robbin -
贫血的Domain Model ...
我想robbin的意思其实是如果只有一个client,也就是在只有web层用它的 ...
-- by taowen -
贫血的Domain Model ...
taowen 写道 连接的获取和释放,和事务的管理是Service层的职责,无论 ...
-- by pig345






评论排行榜