Travis Webb
Travis Webb

Reputation: 15018

What is the correct term for a method whose only purpose is to call another method?

Occasionally there will be a method that calls another method and does nothing else. I'll demonstrate with an example:

void foo() {
    bar();
}
void bar() {
    // do some actual work
}

Is there some precise terminology that could be used to describe method foo? I've sometimes seen these called "bridge" methods, but I know this to be incorrect, since a "bridge method" has a separate, well-defined meaning. Any help is appreciated, thanks.

Upvotes: 1

Views: 228

Answers (2)

Andy Thomas
Andy Thomas

Reputation: 86409

It's a Wrapper Function.

Contrary to @scrappedcola's comment, a wrapper function is not necessarily wasteful and redundant. An instance may satisfy an interface, or forward a call.

Upvotes: 15

Brandon Moretz
Brandon Moretz

Reputation: 7621

Sounds like a simple Proxy Pattern

Upvotes: 3

Related Questions