⇒ 기능의 뼈대와 실제 기능 구현을 분리한다.
⇒ 확장 / 변화가 필요한 부분(실제 기능)만 서브 클래스로 구현할 수 있도록 한다.

abstract class AbstractClass{
public final void templeteMethod(){
step1();
step2();
if(hook() == true){
step3();
}
}
protected abstract void step1()
protected abstract void step2()
protected abstract void step3()
public boolean hook(){
return true;
}
}
class ConcreteClass extends AbstractClass{
@Override
protected void step1(){
// 적절한 로직
}
@Override
protected void step2(){
// 적절한 로직
}
@Override
protected void step3(){
// 적절한 로직
}
@Override
public boolean hook(){
// 적절한 로직
return true;
}
}
// client
class Main{
public static void main(String[] args){
ConcreteClass concreteClass = new ConCreteClass();
concreteClass.templeteMethod();
}
}