CSC/ECE 517 Fall 2012/ch2a 2w23 sr: Difference between revisions
Line 40: | Line 40: | ||
== Example == | == Example == | ||
== Advantages == | == Advantages == | ||
* | *Increased encapsulation: | ||
The responsibility-driven approach emphasizes the encapsulation of both the structure and behavior of objects by focusing on the contractual responsibilities of a class.The benefit is increased encapsulation, since the specification of the exact way in which a request is carried out is private to the server. Encapsulation is compromised when the structural details of an object become part of the interface. Responsibility-driven designs maximize encapsulation by ignoring the structural details. | The responsibility-driven approach emphasizes the encapsulation of both the structure and behavior of objects by focusing on the contractual responsibilities of a class. l It improves encapsulation with respect to subclass clients [Halb86], ensuring that all inherited behavior is part of the contract of the subclass. The benefit is increased encapsulation, since the specification of the exact way in which a request is carried out is private to the server. Encapsulation is compromised when the structural details of an object become part of the interface. Responsibility-driven designs maximize encapsulation by ignoring the structural details. | ||
* Facilitates polymorphism | *Facilitates polymorphism: | ||
By encouraging the designer to focus on responsibilities independently of implementation, the responsibility driven approach can help a designer identify standard protocols (message names), which facilitates polymorphism. It makes abstract classes easier to identify. One difficulty in identifying abstract classes lies in determining what parts of the protocol of existing classes are parts of the type of those classes, and what parts are implementation details. Because the protocol of a class includes only those messages which form the type of the class, this problem is eliminated. | |||
== Comparison == | == Comparison == |
Revision as of 00:23, 27 October 2012
Responsibility-Driven Design
Introduction
Object-oriented programming(OOP) language enable software to be reusable, refinable, testable, maintainable, and extensible by supporting encapsulation. In order to realize these advantages, encapsulation should be maximized during the design process. other techniques attempt to enforce encapsulation during the implementation phase. This is too late in the software life-cycle to achieve maximum benefits.
Responsibility-driven design(RRD) is an alternate design method to focus on increasing the encapsulation by viewing a program in terms of the client/server model.<ref>http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach</ref> This method was proposed by Rebecca Wirfs-Brock and Brian Wilkerson.
Definition
RRD is defined as follows:
Responsibility-driven design is inspired by the client/server model. It focuses on the contract by asking:
- What actions is this object responsible for?
- What information does this object share?<ref>http://dl.acm.org/citation.cfm?doid=74877.74885 Object-oriented design: a responsibility-driven approach</ref>
Responsibility-driven design principles and constructs
Principles
- Maximize Abstraction
Initially hide the distinction between data and behavior.
Think of objects responsibilities for “knowing”, “doing”,and “deciding”.
- Distribute Behavior
Promote a delegated control architecture.
Make objects smart—-have them behave intelligently, not just hold bundles of data.
- Preserve Flexibility
Design objects so interior details can be readily changed.
Constructs
- 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 <ref>http://oreilly.com/javascript/excerpts/learning-javascript/javascript-datatypes-variables.html JavaScript Data Types and Variables</ref>
Example
Advantages
- Increased encapsulation:
The responsibility-driven approach emphasizes the encapsulation of both the structure and behavior of objects by focusing on the contractual responsibilities of a class. l It improves encapsulation with respect to subclass clients [Halb86], ensuring that all inherited behavior is part of the contract of the subclass. The benefit is increased encapsulation, since the specification of the exact way in which a request is carried out is private to the server. Encapsulation is compromised when the structural details of an object become part of the interface. Responsibility-driven designs maximize encapsulation by ignoring the structural details.
- Facilitates polymorphism:
By encouraging the designer to focus on responsibilities independently of implementation, the responsibility driven approach can help a designer identify standard protocols (message names), which facilitates polymorphism. It makes abstract classes easier to identify. One difficulty in identifying abstract classes lies in determining what parts of the protocol of existing classes are parts of the type of those classes, and what parts are implementation details. Because the protocol of a class includes only those messages which form the type of the class, this problem is eliminated.
Comparison
Conclusion
References
<references/>