What is the name of this inheritance design pattern?

Instead of a public virtual method, you have a public method that calls a protected virtual method. Something like that:

public class Test {

    public void DoStuff(){
        // Do stuff here...
        ProtectedDoStuff();
        // Do more stuff...
    }

    protected virtual void ProtectedDoStuff(){
        // Do stuff...
    }
}

Instead:

public class Test {

    public virtual void DoStuff(){
        // Do stuff here...
        // Do a lot of stuff...
        // Do more stuff...
    }
}

public class Test2 : Test {

    public override void DoStuff(){
        // Do same stuff as base
        // Do different stuff
        // Do more stuff just like base
    }
}

This avoids the re-implementation of all functions from the public method, if needed all the time. I know this has already been asked in stackoverflow, but I cannot find the question.

+4
source share
1 answer

This is a template template. From Wikipedia :

, , , . .

+5

All Articles