OOD架构设计模式中MVC与ECB

时间比较紧,先转再翻

http://www.cs.sjsu.edu/~pearce/modules/lectures/ooa/analysis/ecb.htm

日后有相关类似资源将不断更新

The Entity-Control-Boundary Pattern

The analysis object model instantiates theEntity-Control-Boundary Pattern (ECB)

ECB is a simplification of the Model-View-ControllerPattern.

ECB partitions the system into three types of classes:entities, controls, and boundaries.

entity, control, and boundary are official UML classstereotypes. UML has some special icons to represent them:

Here's the same diagram without the special icons:

Entities

Entities are objects representing system data: Customer,Product, Transaction, Cart, etc.

实体类:在系统中充当数据载体的类型,通常来自现实问题中的实体

Boundaries

Boundaries are objects that interface with system actors:UserInterface, DataBaseGateway, ServerProxy, etc.

边界类:系统和外界环境的接口,按照我的理解可以是各种输入数据的来源,文中提到的actor不专指用户,对于一个软件系统来说,所有与之交互,使用其功能的外部实体都可以算作actor


Controls

Controls are objects that mediate between boundaries andentities. They orchestrate the execution of commands coming from the boundaryby interacting with entity and boundary objects. Controls often correspond touse cases and map touse casecontrollers in the design model.

控制类:根据边界类收到的信息,对实体类进行相应的操作,换句话说就是封装了业务逻辑,所以控制类一般和一个或多个用例对应

Internal Dynamics

Associated with every control in the analysis model is astatechart diagram representing the control's internal logic.

表示控制类的内部逻辑

For example:

External Dynamics

Associated with every control is a sequence diagramrepresenting the control's interactions with boundaries, entities, and othercontrols.

表示一个控制类和边界类、实体类以及其他控制类之间的互动逻辑

For example:

Model-View-Controller Pattern

Application data and logic (encapsulated by the model)should be independent of presentation logic (encapsulated by the views andcontrollers).

基本要义:应用的数据和逻辑(对应Model)应当独立于数据的表示逻辑(应该指软件的I/O以及交互逻辑,对应View和Controller)


Views are responsible for user input and output. A dialogbox is a good example of a view. Controllers implement the logic for theallowable transactions that can be performed on the model. The model encapsulatesthe fine grained business logic and data.

视图的职责是向用户提供IO接口,而控制器实现对Model操作的业务逻辑。Model则封装了实体的数据和细粒度的业务逻辑

- 想法:这里的Application data & logic应该是指现实中实体的属性和内在的逻辑(比如香蕉是黄的,可以吃,等等),而不是业务逻辑(用户想要把香蕉炒着吃,该怎么把香蕉炒了送出去,等等)


Here's a sequence diagram showing the interaction:


The Model-View-Controller Architecture

We refine the multi-layer pattern with the Model-View-Controllerpattern:

If our domain layer consists of many classes, we might wantto introduce the Facade pattern to promotedecoupling between the presentation package and the domain package.

如果domain层包含多个类,那么可以考虑引入门面(Facade)模式来实现presentation包和domain包之间的解耦

View Notification

How can the model notify all views when it has been updatedwithout introducing a dependency on them? To solve this problem we can refinethe Model-View-Controller pattern with thePublisher-Subscriberpattern:

通过发布/订阅模式,在不引入依赖关系的前提下实现将model的修改通知到所有视图对象

 



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值