Is it ok to design DTOs/parameter wrapper objects as inner classes? Is it common practice or does it have any major drawbacks? E.g:
//I want to initiate threads with parameters
public class TradeBot implements Callable<TradingReport> {
//I have a few parameters, so I decided to wrap those into an object
TradeBotParamDTO params;
//the wrapper for parameters is actually an inner class:
public class TradeBotParamDTO {
JsonNode config;
Instrument instrument;
TimeframeBarMQL tf;
int numberOfBars;
int port;
String host;
}
//Constructor to instantiate the Runnable with parameters
public TradeBot(TradeBotParamDTO params) {
super();
this.params = params;
}
@Override
public TradingReport call() {
//access params here...
params.getXXX()
...
}
}
Aucun commentaire:
Enregistrer un commentaire