CSC/ECE 517 Fall 2010/ch7 7f PW

From Expertiza_Wiki
Revision as of 01:28, 29 November 2010 by Phwetsel (talk | contribs)
Jump to navigation Jump to search

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 and is required to call super() first, that is a case of this anti-pattern. It is not a good idea to require something else being called first.

Examples

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


References

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

[2] MF Bliki: Call Super[2]