Object Design: Roles, Responsibilities, and Collaborations
概要:讲述的是面向对象的的基本理论。对像设计中的:角色,职责,协作!
面向对象设计是管理的哲学,是数学的哲学,是自我管理之径,是思考的之径
参考中文文章:http://www.blogjava.net/sslaowan/archive/2007/03/20/104987.html
Chapter 1. Design Concepts
Alan Kay's favorite metaphor for software objects is a biological system.
A software object may be machinelike, but, crafted by a thoughtful designer, it can be very smart. It makes decisions; it does things and knows things. It collaborates with potentially many other objects. Living in an enclosing machine, it is a whole on one level and a part on another.--->对象是死的,可是聪明的设计者能够赋予它能力:能够做选择,做事情,拥有信息,协作。从不同角度去看对象它可以是某个整体的一部分,也可以是一个独立的主体。
Object Machinery
A software application is constructed from parts. These parts software objects interact by sending messages to request information or action from others. Throughout its lifetime, each object remains responsible for responding to a fixed set of requests. To fulfill these requests, objects encapsulate scripted responses and the information that they base them on :knows infomation,maintains connections to other objects,performs services,makes decisions to do the right thing. If an object is designed to remember certain facts, it can use them to respond differently to future requests--->一个对象:知道一些信息,维持一些和其它对象的链接,执行一些服务,做出一些决定去做一些正确的事情
Software objects display information, coordinate activities, compute, or connect to services. The bulk of this machine is our invention! We follow a real-world metaphor forms and files put our object model includes a much richer set of concepts that are realized as objects. --->我们对现实进行隐喻,把丰富的现实世界抽象成为我们的对象模型。
If we keep our focus on the behavior, we can design the application using several complementary perspectives:---->关于程序我们可以形成如下看法:
An application = |
a set of interacting objects |
An object = |
an implementation of one or more roles |
A role = |
a set of related responsibilities |
A responsibility = |
an obligation to perform a task or know information |
A collaboration = |
an interaction of objects or roles (or both) |
A contract = |
an agreement outlining the terms of a collaboration |
Roles
A role is a set of responsibilities that can be used interchangeably.
|
It is useful to think about an object, asking, "What role does it play?" This helps us concentrate on what it should be and what it should do. We have been speaking of objects and roles loosely. What is the real difference? When a role is always played by the same kind of object, the two are equivalent. But if more than one kind of object can fulfill the same responsibilities within the community, a role becomes a set of responsibilities that can be fulfilled in different ways. A role is a slot in the software machinery to be filled with an appropriate object as the program runs. ---->什么是角色,角色和对象的区别?
Object Role Stereotypes
A well-defined object supports a clearly defined role. We use purposeful oversimplifications, or role stereotypes, to help focus an object's responsibilities. --->好的对象有明晰的角色定位!
Because our goal is to build consistent and easy-to-use objects, it is advantageous to stereotype objects, ignoring specifics of their behaviors and thinking about them at a higher level. By oversimplifying and characterizing it, we can ponder the nature of an object's role more easily. We find these stereotypes to be useful:
-
Information holder nows and provides information
-
Structurer maintains relationships between objects and information about those relationships
-
Service provider performs work and, in general, offers computing services
-
Coordinator reacts to events by delegating tasks to others
-
Controller takes decisions and closely directs others' actions
-
Interfacer transforms information and requests between distinct parts of our system
But is it playing one or two roles? Often we find that a service provider holds information that it needs to provide its service. In doing so, it assumes two stereotypes information holder and service provider put only one role because the responsibilities are all wrapped up together for the same customers to use. If its information is being used solely to support its service, it assumes two stereotypes but only one role. But if it is perceived as serving two different types of clients for different purposes, it is likely playing two roles.
Some objects are hard to stereotype because they seem to fit into more than one category. They're fuzzy. How can you choose? You must decide what you want to emphasize. A transmission is a service provider if you emphasize the multiplication of power by the gears. It is an interfacer if you emphasize its connections to the engine and wheels. Can objects have more than one stereotype? If you want to emphasize more than one aspect, that's OK. There are blends of stereotypes, just as there are blends of emphasis.
分享到:
相关推荐
《UML对象设计与编程ObjectDesign》是一门深入探讨如何将UML(统一建模语言)分析技术应用于实际对象设计的课程。UML作为一种标准化的建模语言,为软件开发提供了一种可视化、规范化的表达方式,使得项目团队能够更...
《Design Patterns Explained: A New Perspective on Object Oriented Design》这本书提供了一种新的视角来理解和应用这些模式。以下是关于设计模式的一些关键知识点: 1. **工厂模式**:工厂模式是一种创建型设计...
Upon completion of an object-oriented design, you are faced with a troubling question: "Is it good, bad, or somewhere in between?" Seasoned experts often answer this question by subjecting the design ...
Design Patterns Explained: A New Perspective on Object-Oriented Design By Alan Shalloway, James R. Trott Publisher : Addison Wesley Pub Date : July 09, 2001 ISBN : 0-201-...
Data Structures And Algorithms With Object-oriented Design Patterns In Java.chm
- **引入参数对象(Introduce Parameter Object)**:当方法拥有大量参数时,将其转换为一个单独的对象,以增强代码的可读性和可维护性。 #### 案例研究 通过对实际项目的深入剖析,读者可以更加直观地理解面向对象...
Systems Analysis and Design: An Object-Oriented Approach with UML, 5th Edition by Dennis, Wixom, and Tegarden captures the dynamic aspects of the field by keeping students focused on doing SAD while ...
Upon completion of an object-oriented design, you are faced with a troubling question: "Is it good, bad, or somewhere in between?" Seasoned experts often answer this question by subjecting the design ...
在计算机科学领域中,“面向对象分析和设计(Object-Oriented Analysis and Design)”是一门核心的课程内容,尤其对于本科学生来说,它覆盖了从基础理论到最终课题和应用的广泛主题。本课程由UTiCS(Undergraduate ...
这是ibm的课件:Mastering Object-Oriented Analysis and Design with UML,中文的在CSDN已有同学上传~建议中英文对照着看,因为中文有的翻译不是很恰当
Capturing a wealth of experience about the design of object-oriented software, four top-notch designers present a catalog of simple and succinct solutions to commonly occurring design problems....
《Object Oriented Design in Java》是Mitchell Waite Signature Series中的一部著作,由Stephen Gilbert和Bill McCarty共同撰写。这本书深入探讨了如何在Java语言中进行面向对象设计(OOD),帮助开发者掌握这一...
Data Structures and Algorithms with Object-Oriented Design Patterns in C++.rar Data Structures and Algorithms with Object-Oriented Design Patterns in C++.rar
Design Patterns Explained A New Perspective on Object Oriented Design 2nd Edition 这本就是《设计模式解析》(2nd)的英文版
《Head First Object Oriented Analysis and Design》是一本深入浅出介绍面向对象分析与设计的书籍,旨在帮助读者理解和掌握这一核心的软件开发技术。书中的内容不仅覆盖了基础的面向对象概念,还涉及到了实际应用中...
Head First Object-Oriented Design and Analysis 英文版,共3个文件