I have this existing class setup. This is my entrypoint class.
public class AppManager {
public AppManager() {
}
public void startApp(){
doInit();
if(doTask1())
doTask2();
else
doTask3();
createUI()
}
public void doInit() {
InitClass initClass = new InitClass();
initClass.init();
}
public boolean doTask1() {
Task1 task1 = new Task1();
return task1.doTask();
}
public boolean doTask2() {
Task2 task2 = new Task2();
return task2.doTask();
}
public boolean doTask3() {
Task3 task3 = new Task3();
return task3.doTask();
}
public void createUI() {
UIManager uiManager = new UIManager();
uiManager.createUI();
}
public static void main(String[] args) {
AppManager appManager = new AppManager();
appManager.startApp();
}
}
I wanted to do some refactoring of it. I think it is doing a bit of things but I don't know how? I tried to create the task Specific class so that I can delegate the work to them.
But I think my entrypoint class is still doing a lot of things. According to good design "a class should only be doing one thing".
There are other tasks that I have ommitted intentionally for brevity.
Not sure if my question is clear but I just wanted to improve my code.
I have used java code in this case but I think this is still applicable to other languages.
How to refactor?
Aucun commentaire:
Enregistrer un commentaire