UML基本架构建模--类的通用建模技术(二)



Modeling the Distribution of Responsibilities in a System

为系统的职责分配建模

Once you start modeling more than just a handful of classes, you will want to be sure that your abstractions provide a balanced set of responsibilities. What this means is that you don’t want any one class to be too big or too small. Each class should do one thing well. If you abstract classes that are too big, you’ll find that your models are hard to change and are not very reusable.if you abstract classes that are too small, you’ll end up with many more abstractions than you can reasonably manage or understand. You can use the UML to help you visualize and specify this balance of responsibilities.

一旦开始建模,你就不仅仅是考虑那些类,还要确保你的抽象事物提供职责集合的平衡.这指的是你不希望任何一个类太大或是太小.每个类应该做好一件事.如果你的抽象类太大,你会发现你的模型将很难改变并且不可重复使用.如果你的抽象类太小,你会有更多的抽象事物,这将让你难以合理地管理或理解.你能使用UML来帮助你可视化和描述这些职责的平衡.

To model the distribution of responsibilities in a system,

在系统中为职责的分配建模,

1. Identify a set of classes that work together closely to carry out some behavior

 为执行一些行为而识别一组密切合作的类

2. Identify a set of responsibilities for each of these classes.

 为这些类中的每个标识一组职责

3. Look at this set of classes as a whole, split classes that have too many responsibilities into smaller abstractions, collapse tiny classes that have trivial responsibilities into larger ones, and reallocate responsibilities so that each abstraction reasonably stands on its own.

 将有太多职责的类划分成更小的抽象事物,削减微小的类,将其不太重要的职责加到更大的类中,并重新分配职责,以便每个抽象有清晰的独立性.

4. Consider the ways in which those classes collaborate with one another and redistribute their responsibilities accordingly so that no class within a collaboration does too much or too little.

 考虑如何让那些类与其它的类交互,考虑重新分配它们的职责以便在协作中的类不会太多或是太少.

For example, Figure 4-10 shows a set of classes drawn from Smalltalk, showing the distribution of responsibilities among Model, View, and Controller classes. Notice how all these classes work together such that no one class does too much or too little.

举个例子,如图4-10显示的来自SmallTalk的一组类,显示的是在模型,视图和控制器三个类之间的职责分配.注意所有这些类是如何一起工作,这些没有一个类的职责太多或太少.

时间: 2024-08-25 14:16:51

UML基本架构建模--类的通用建模技术(二)的相关文章

UML基本架构建模--类的通用建模技术(一)

 Modeling the Vocabulary of a System 为系统的词汇表建模 You'll use classes most commonly to model abstractions that are drawn from the problem you are trying to solve or from the technology you are using to implement a solution to that problem. Each of thes

UML基本架构建模--类的通用建模技术(三)

 Modeling Nonsoftware Things 构建非软件事物模型 Sometimes, the things you model may never have an analog in software. For example, the people who send invoices and the robots that automatically package orders for shipping from a warehouse might be a part of

UML基本架构建模--类的通用建模技术(四)

 Modeling Primitive Types 构建原始类型模型 At the other extreme, the things you model may be drawn directly from the programming language you are using to implement a solution. Typically, these abstractions involve primitive types, such as integers, charac

UML基本架构建模--获取类

 Getting Started 开始 Modeling a system involves identifying the things that are important to your particular view. These things form the vocabulary of the system you are modeling. For example, if you are building a house, things like walls, doors, w

UML基本架构建模--类的辅助信息

 Organizing Attributes and Operations 组织属性和操作 When drawing a class, you don't have to show every attribute and every operation at once. In fact, in most cases, you can't (there are too many of them to put in one figure) and you probably should not

UML基本架构建模--通用机制的术语和概念(四)

 Constraints 约束 Everything in the UML has its own semantics. Generalization (usually, if you know what's good for you) implies the LisKov substitution principle, and multiple associations connected to one class denote distinct relationships. With c

微服务架构下静态数据通用缓存机制

在分布式系统中,特别是最近很火的微服务架构下,有没有或者能不能总结出一个业务静态数据的通用缓存处理机制或方案,这篇文章将结合一些实际的研发经验,尝试理清其中存在的关键问题以及探寻通用的解决之道. 什么是静态数据 这里静态数据是指不经常发生变化或者变化频率比较低的数据,比如车型库.用户基本信息.车辆基本信息等,车型库这种可能每个月会更新一次,用户和车辆基本信息的变化来源于用户注册.修改,这个操作的频率相对也是比较低的. 另外这类数据的另一个特点是要求准确率和实时性都比较高,不能出现丢失.错误,以及

大气智能家居家具装修装饰类企业通用网站织梦模板【dedecms模板】

模板名称:大气智能家居家具装修装饰类企业通用网站织梦模板模板介绍:织梦最新内核开发的模板,适合智能家居家具企业,也可以通用装修行业等企业使用,页面简洁简单,容易管理,DEDE5.5内核以上都可以使用:附带测试数据! 模板特点:1:智能家居家具展示公司模板,代码简洁,风格大气简单,页面干净.2:首页带炫酷的幻灯片,产品展示,新闻展示.3:网站内容都能在后台修改,后台简单易学.4:后台直接修改联系方式.地址.版权信息,网站内容等,修改更加方便. 使用程序:织梦DEDECMS5.5以上版本都可以使用.

基于类的通用视图

基于类的通用视图 前面我们说过了django的通用视图,不知道django通用视图的去看我前面的随笔,谢谢 django的通用视图帮我们省略了很多代码,但有时候django的通用视图并不能满足我们全部的需求,例如像重定义一些属性和方法的时候,或者我们想换种写法的时候,因此,django提供了基于类的通用视图,通过子类或者在url中传参的方法来配置我们的基于类的通用视图 通用视图和基于类的通用视图是两种不一样的写法,前面我们介绍的通用视图,所有的代码集中于url的配置文件中,而基于类的通用视图主要