CSC/ECE 517 Fall 2010/ch7 7f PW: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
Line 13: Line 13:
   public void handle() {
   public void handle() {
     super.setup();
     super.setup();
     setupForTCOne();
     extraSetupForTestCaseOne();
   }
   }


</pre>
</pre>


==References==
==References==

Revision as of 00:45, 30 November 2010

The Call Super Anti-pattern

What is the Call Super Anti-pattern

The Call Super anti-pattern shows up occasionally in object oriented code. Any time an inherited class overrides a method but is still required to call super() at some point during the method, then that is a case of this anti-pattern. It is not a good idea to require something else being called at some point during the method.
Call Super Anti-pattern

Examples

public class TestCase
  public void setup() {
    doStuff();
  }
public class TestCaseOne extends TestCase
  public void handle() {
    super.setup();
    extraSetupForTestCaseOne();
  }

References

[1] Wikipedia, the free encyclopedia: Call Super, 2010. Wikimedia Foundation, Inc.: [1]

[2] MF Bliki: Call Super[2]