call super
Call super is a code smell or anti-pattern of some object-oriented programming languages.[src] Call super is a design pattern in which a particular class stipulates that in a derived subclass, the user is required to override a method and call back the overridden function itself at a particular point.[src] The overridden method may be intentionally incomplete, and reliant on the overriding method to augment its functionality in a prescribed manner.[src] However, the fact that the language itself may not be able to enforce all conditions prescribed on this call is what makes this an anti-pattern.[src]
Call super is a code smell or anti-pattern of some object-oriented programming languages.[src] Call super is a design pattern in which a particular class stipulates that in a derived subclass, the user is required to override a method and call back the overridden function itself at a particular point.[src] The overridden method may be intentionally incomplete, and reliant on the overriding method to augment its functionality in a prescribed manner.[src] However, the fact that the language itself may not be able to enforce all conditions prescribed on this call is what makes this an anti-pattern.[src] abstract class ReportGenerator { public virtual Report CreateReport() { // Generate the general report object // ...[src] return new Report(...); } } A user of the class is expected to implement a subclass like this: class ConcreteReportGenerator : ReportGenerator { public override Report CreateReport() { // Tabulate data in the store-specific way // ...[src] // Design of this class requires the parent CreateReport() function to be called at the // end of the overridden function.[src] But note this line could easily be left out, or the // returned report could be further modified after the call, violating the class design // and possibly also the company-wide report format.[src] return base.CreateReport(); } } A preferable interface looks like this: abstract class ReportGenerator { public Report CreateReport() { Tabulate(); // Generate the general report object // ...[src] return new Report(...); } protected abstract void Tabulate(); } An implementation would override this class like this: class ConcreteReportGenerator : ReportGenerator { protected override void Tabulate() { // Tabulate data in the store-specific way // ...[src] } }[src]
15 sentences · 15 cited inline · 0 references stored
References
No reference rows published for this article.
Cite this article
MLA
"call super." encyclopegia.org, 2025, https://encyclopegia.org/wiki/call-super. Accessed 27 November 2026.
Chicago
"call super." encyclopegia.org. Accessed November 27, 2026. https://encyclopegia.org/wiki/call-super.
APA
encyclopegia.org. (2025). call super. Retrieved November 27, 2026, from https://encyclopegia.org/wiki/call-super
Accessed November 27, 2026 · CC BY-SA 4.0 · citation page · JSON