摘要:在上面三种模型之外,还有很多这三种模型的变种,例如partech的模型就是把第二种模型中的DAO和Manager三个类合并为一个类后形成的模型;例如frain....(id很长记不住)的模型就是把第三种模型的三个类完全合并为一个单类后形成的模型;例如Archie是把第三种模型的Item又分出来一些纯数据类(可能是,不确定)形成的一个模型。 但是不管怎么变,基本模型归纳起来就是上面的三种模型,下面分...
阅读全文
摘要:第三种模型印象中好像是firebody或者是Archie提出的(也有可能不是,记不清楚了),简单的来说,这种模型就是把第二种模型的domain object和business object合二为一了。所以ItemManager就不需要了,在这种模型下面,只有三个类,他们分别是: Item:包含了实体类信息,也包含了所有的业务逻辑 ItemDao:持久化DAO接口类 ItemDaoHibernate...
阅读全文
摘要:第二种模型,也就是Martin Fowler指的rich domain object是下面这样子的: 一个带有业务逻辑的实体类,即domain object是Item 一个DAO接口ItemDao 一个DAO实现ItemDaoHibernateImpl 一个业务逻辑对象ItemManager java 代码 public class Item implements Seriali...
阅读全文
摘要:第一种模型:只有getter/setter方法的纯数据类,所有的业务逻辑完全由business object来完成(又称TransactionScript),这种模型下的domain object被Martin Fowler称之为“贫血的domain object”。下面用举一个具体的代码来说明,代码来自Hibernate的caveatemptor,但经过我的改写: 一个实体类叫做Item,指的是...
阅读全文
摘要:Composite Definition Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and composition...
阅读全文
摘要:Definition Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality. ...
阅读全文
摘要:Adapter Definition Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because ...
阅读全文
摘要:Definition Provide a surrogate or placeholder for another object to control access to it. UML class diagram Participants ...
阅读全文
摘要:Definition Use sharing to support large numbers of fine-grained objects efficiently. UML class diagram Participants ...
阅读全文
摘要:Definition Provide a unified interface to a set of interfaces in a subsystem. Façade defines a higher-level interface that makes the subsystem easier to use. ...
阅读全文
摘要:Definition Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable o...
阅读全文
摘要:Definition Define a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically. ...
阅读全文
摘要:Definition Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation. UML class ...
阅读全文