I am new with design pattern, and I don't know which I have to apply in this case. I have some data in a file, so I have to model that data and then start a class with that data.
For the reading of the file and the modeling I choose to apply the Dao pattern, so there is interface (Interface) and his implementation (InterfaceImplementation) that read the file and return the model data (DataModel). After I have to instantiate another class (Runner) with that model data e call one of its method. This is what I have done:
public class Factory {
public void start() {
Interface dao = new InterfaceImplementation();
DataModel data = dao.getDataModel();
Runner runner = new Runner(data);
runner.run();
}
}
So the client call only the method new Factory().start()
.
I have some doubts about this solution, I don't think this is a good solution and a good applying of the Factory pattern.
I hope to have been clean, cheers.
Aucun commentaire:
Enregistrer un commentaire