GRASP_Patterns.ppt

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
GRASP_Patterns.ppt

GRASP Patterns Best Practices for Object-Oriented Software Design GRASP Patterns GRASP: Generalized Responsibility Assignment Software Patterns GRASP patterns are really more accurately described as best practices GRASP patterns outline best practices which can be employed in any object-oriented design These best practices, if used properly, will lead to maintainable, reusable, understandable, and easy to develop software GRASP Patterns GRASP patterns describe how to assign responsibilities to classes Warning: Grasps tend to be vague Responsibilities is “a contract or obligation of a classifier” (UML definition) Responsibilities can include behaviour, data storage, object creation and more They often fall into two categories: Doing Knowing 1. Information Expert Assign a responsibility (such as behaviour) to the information expert An information expert is the class that has (or has direct access to) the information necessary to fulfill the responsibility e.g. A responsibility such as handling a deposit (i.e. increase balance) should be assigned to the Account class This is because Account contains the account balance as one of its attributes 1. Information Expert This GRASP has the effect of having a class with high cohesion Cohesion – the degree to which the information and responsibilities of a class are related to each other Cohesion is improved since the information needed for a responsibility is closely related to the responsibility itself 2. Creator Give a class A the responsibility of creating instances of another class, B, if: A is an aggregate of B A is a container of B If no classes apply, then assign the responsibility to a class C if: C records instances of B C closely uses B objects C has the initializing data for B 2. Creator Whenever one class has the responsibility of creating instances of another class, the two classes are coupled Coupling itself is not wrong, but we want to eliminate certain types of coupling Coupling of classes is a measure of ho

文档评论(0)

暖洋洋 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档