I have a class doing translate job. But it have hundreds of specific translate methods! The action code determine which method will be used! I want to use strategy pattern, but it will create hundreds of sub class! I want to name the methods end of action code and use reflection to do the translate, but I'm concern abort the execution performances. It will be called very frequently! What design pattern or patterns should I use to solve this problem! code like this:
public class Test003_Translate {
public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
Test003_Translate translate = new Test003_Translate();
String prefix = "translate";
String actionCode = "001";
Method method = Test003_Translate.class.getMethod(prefix + actionCode);
method.invoke(translate);
}
public void translate001(){
;
}
public void translate002(){
;
}
public void translate003(){
;
}
...
public void translate200(){
;
}
}
Aucun commentaire:
Enregistrer un commentaire