我想知道是否可以通过特定的设计模式来概括Java程序的输入和输出部分?我正在寻找一种方法来使用模式在将来添加不同类型的实现。例如,假设我有一个根据输入计算某些内容的方法,并且它通过 Console 工作。如何概括此应用程序的输入输出端,以便可以轻松添加 GUI 或 Web 服务等其他输入/输出实现?
public int compute(int input){
return input+2;
}
最佳答案
How can I generalize the input-output side of this application in a way that other implementation of input/output like GUI or web service can be added easily
让我想到Model View C Controller ,您希望能够在哪里更改“ View ”? (view也可以是webservice)
关于java - 通用的java输入输出设计模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42485525/