管理或控制器设计模式。我有一个班在结构上做两个不同的工作。是否有一种设计模式以更加可维护的方式重构它?或者,我应该如何以更加可维护的方式划分这个类?
Management Class does
Task launching recovery management
- create Callable Task - if thread failed to start, re-assign
- submit tasks to ExecutorService the same task to other thread
- start ExecutorService - if task is not halted unexpectedly,
- get result of each task re-assign the task to new thread
- if thread halted, get already done
job and restart the thread for
not done jobs
- other task and thread related recovery
scenarios
Settings
- set requirements of management class in system level
- determine optimal number of threads should be run
- determine optimal number of task to be created
- create and manage system configuration file - store system settings, get system
settings-
在进行投票或试图关闭之前,如果你是建设性的,请写评论,以便我解决它。
答案 0 :(得分:0)
您想申请SRP:Single Responsibility principle。
事实上,在你的情况下,你的实际课程做得太多了:它有三个职责:
我会把你的全班分成三个班级:
请注意,它不是设计模式,而是SOLID原则的一部分。