The template method is what you want. This is one of the oldest, just a formalization of the way you compose your classes.
http://en.wikipedia.org/wiki/Template_method_pattern
or as in this code example:
abstract class AbstractParent // this is the template class
{
final void executeIt()
{
doBefore();
doInTheMiddle()
doLast();
}
abstract void doBefore();
abstract void doInTheMiddle();
final void doLast(){ .... }
}
class SubA extends AbstractParent
{
void doBefore(){ ... does something ...}
void doInTheMiddle(){ ... does something ...}
}
class SubB extends SubA
{
void doBefore(){ ... does something different ...}
}
But it looks like you are catching the opportunity to use a pattern, rather than using a pattern to solve a specific type of problem. This will only lead to poor software development.
Do not think about templates. Think about how you will solve the problem without having templates.
Imagine there were no codified patterns (as it was before). How would you accomplish what you want to do here (this is what people did to solve such problems). When you can do this, then you will be in a much better position to understand the patterns.
. , .