CSC/ECE 517 Fall 2010/ch3 S30 RJ: Difference between revisions
Line 5: | Line 5: | ||
== '''Decomposition in OOP Design''' == | == '''Decomposition in OOP Design''' == | ||
A | A useful starting definition for Decomposition in OOP is | ||
"In OO decomp, we think in terms of identifying active, autonomous agents which are responsible for doing the work, and which communicate with each other to get the overall problem solved." [http://www.atomicobject.com/pages/Motivation+for+OO] | "In OO decomp, we think in terms of identifying active, autonomous agents which are responsible for doing the work, and which communicate with each other to get the overall problem solved." [http://www.atomicobject.com/pages/Motivation+for+OO] | ||
Revision as of 03:08, 5 October 2010
Decomposition, Message Forwarding, and Delegation versus Inheritance in OOP Design
Most OOP overviews explain what the concept of Inheritance is in Object Oriented Programming, and how Inheritance works, but not many OOP overviews discuss alternatives when Inheritance may not be the best design choice for an OO application. This topic briefly explains the OOP concepts of Decomposition, Message Forwarding, and Delegation, and then discusses when these concepts could be considered as potential alternatives to the use of Inheritance for some OOP applications.
Decomposition in OOP Design
A useful starting definition for Decomposition in OOP is "In OO decomp, we think in terms of identifying active, autonomous agents which are responsible for doing the work, and which communicate with each other to get the overall problem solved." [1]
The 'autonomous agents' mentioned above would correspond to leveraging known classes and their various objects to get a task or process done, rather than taking the time to design a grand Superclass and subclass inheritance hierarchy which contains all the needed objects and classes that are needed to address a given task or process. Mixins in Ruby on Rails would be an example of decomposition in OOP, since Mixins allow useful methods from classes to be easily mixed-in, or used as utility methods by classes that may not be suitably related in a traditional inheritance hierarchy.
Message Forwarding versus Inheritance in OOP Design
Delegation versus Inheritance in OOP Design
This is a test URL link BobJ PCTOGO
- This is a reference to the PC-To-Go web site <ref>PC To GO</ref>
This is an internal link referenceand a citation [1]
References:
References: <references/>