I and doing an app in Android which can run different ML models and I want to create some classes to represent the data of the results, each ML model has it owns variables/result, for example, a classification problem has labels meanwhile other do not have them.
I want to use inheritance in java and doing something like Result as interface and father of ClassificationResult and RegresionResult so I could do:
Arraylist<Result> resultList;
ClassificationResult cr = new ClassificationResult...
RegresionResult rr = new RegresionResult...
resultList.add(cr)
resultList.add(rr)
But I face the problem that I cannot call methods from the children like ClassificationResult.getLabels() (I could have all the method of all the children in the interface but it seems weird for me)
I saw some patterns, Factory and Builder but I face the previously described problem with the Factory pattern and with the Builder (having all the variables in one class) most of them would not be initialized.
I would appreciate some ideas about how I should design this
Aucun commentaire:
Enregistrer un commentaire