在常见的桌面的应用程序中,通常包括了UI、业务逻辑、后台数据库等三大模块以及online、batch两大运行模式。为了解耦各组件,我们通常采用MVC模式,其实现过程如下。
public interface ActionerInterface{
public void doAfterClickCloseBtn();
public void doAfterClickRefreshBtn();
}
public interface ViewerInterface{
public void update();
public void close();
public void show();
}
public class Controller{
private ViewerInterface viewer;
public Controller(){
}
public void showViewer{
ActionerInterface actioner = new Actioner();
viewer = new Viewer(actioner);
viewer.show();
}
public void updateViewer(){
viewer.update();
}
public void closeViewer{
viewer.close();
}
}