Recursion introduction

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
(New page: When an operation need the method in one class to communicate to a method another class, then the interface of these two class (the method) should be named the same. If it happens to be th...)
 
m (Reverted edits by Ebybymic (Talk); changed back to last version by Jenny Harlow)
 
(6 intermediate revisions by 5 users not shown)
Line 1: Line 1:
When an operation need the method in one class to communicate to a method another class, then the interface of these two class (the method) should be named the same. If it happens to be the case where such two methods in the same class, then a logical recursive method is formed, this is defined as recursion introduction by Johnson and Foote.
+
Giving related messages similar names, even if they have different parameters.
  
According to Johnson and Foote, the benefit of recursion introduction is to help programmer to decide what operation should be a method.
+
When an operation needs the method in one class to communicate with a method in another class, then the interface of these two class (the method) should be named the same. If it happens to be the case where such two methods in the same class, then a logical recursive method is formed, this is defined as recursion introduction by Johnson and Foote.
 +
 
 +
Johnson and Foote call this practice recursion introduction despite the fact that it may not introduce "real" recursion because the method appears to be recursive.
 +
 
 +
According to Johnson and Foote, the benefit of recursion introduction is to help programmers decide in what class the operation should be a method. They use the example of a system converting a parse tree into machine language in which there is a an object representing the parse tree and an object representing the final machine language procedure.  <blockquote>The 'generate code' message could be sent to either object.  However, the best design is to implement the generate code message in the parse tree class, since a parse tree will consist of many parse nodes, and a parse node will generate machine code itself recursively by asking its subtrees to generate code for themselves."{{ref|1}}</blockquote>
 +
 
 +
==References==
 +
#{{note|1}}[[Johnson and Foote 1988| Ralph Johnson and Brian Foote, 1988, Designing reusable classes]]
 +
 
 +
[[Category:Johnson and Foote's heuristics]]

Latest revision as of 03:23, 25 November 2010

Giving related messages similar names, even if they have different parameters.

When an operation needs the method in one class to communicate with a method in another class, then the interface of these two class (the method) should be named the same. If it happens to be the case where such two methods in the same class, then a logical recursive method is formed, this is defined as recursion introduction by Johnson and Foote.

Johnson and Foote call this practice recursion introduction despite the fact that it may not introduce "real" recursion because the method appears to be recursive.

According to Johnson and Foote, the benefit of recursion introduction is to help programmers decide in what class the operation should be a method. They use the example of a system converting a parse tree into machine language in which there is a an object representing the parse tree and an object representing the final machine language procedure.
The 'generate code' message could be sent to either object. However, the best design is to implement the generate code message in the parse tree class, since a parse tree will consist of many parse nodes, and a parse node will generate machine code itself recursively by asking its subtrees to generate code for themselves."[1]

References

  1. ^ Ralph Johnson and Brian Foote, 1988, Designing reusable classes
Personal tools