Re: mvc design doubts
thanks a lot for the suggestions..
I modified the classes accordingly.
class BasicModel implements Observable{
public Result processInputs(String decimalInput,File selectedFile)
{
Result result;
doSomeWork(selectedFile,decimalInput);
result=makeResult();
return result;
}
public void doSomeWork(selectedFile,decimalInput){
try{
//process the data
...
}catch(SomeException e){
String response="specific message"+e.getMessage();
setChanged();
notifyObservers();
}
}
...
}
class ErrorHandler implements Observable{
private BasicView view;
public ErrorHandler(BasicView v){
view=v;
}
public void update (Observable obj, Object arg) {
if (arg instanceof String) {
resp = (String) arg;
view.displayMessage(resp);
}
}
...
}
class Controller{
private BasicView view;
private BasicModel model;
private SimpleUIValidator sValidator;
private StringBuilder errorMsg;
private ErrorHandler errorhandler;
public Controller(BasicView v,BasicModel m){
view=v;
view.addOKButtonListener(new SimpleButtonListener());
model=m;
errorhandler=ErrorHandler(view);
model.addObserver(errorhandler);
}
...
}