在过去的几个月里,我尝试使用函数式编程范例进行编码.现在我有一个OOP解决方案,我正在尝试找到一个功能性解决方案.
问题很简单.我有一个算法,它产生两个不同的数组作为结果(a和b).现在,我想检查结果有多好.因此,我为他们写了几个评估标准.我希望伪java源代码对你没问题!
// first the Algorithm class
class Algorithm {
private []a;
private []b;
Algorithm(input) {
computeResult();
}
getA(){return a;}
getB(){return b;}
void computeResult() {
...
... // time-consuming operations
... // set values for a and b
...
}
}
// this class tests the Algorithm using a list of evaluation criteria
class AlgorithmTest {
AlgorithmTest() {
...
... // Definition of input
... // Definition of list of evaluation criteria evals
...
Algorithm algorithm = new Algorithm(input); // …
Run Code Online (Sandbox Code Playgroud)