I am working on a java project where I've written the domain layer and want to implement a controller using singleton and facade design pattern so that a gui only have to instantiate the controller object once. After the controller object is called I would like the other controllers to be accessed through the frontcontroller.
So fx. if you want to create a new account from the view:
public static FrontController controller = new FrontController();
controller.employee.createAccount("name of user");
to give a better overview here is the file structure:
|> controller
| --> EmployeeController.java
| --> ProjectController.java
| --> FrontController.java
|> view
| --> Init.java
| --> index.fxml
| --> Controller.java
|> domain
| --> Employee.java
| --> Project.java
Here is the frontcontroller; The other controller files are not written yet:
package controller;
public class FrontController {
private static final FrontController instance = new FrontController();
private FrontController(){}
public static FrontController getInstance(){
return instance;
}
EmployeeController employee = new EmployeeController();
ProjectController project = new ProjectController();
}
I'm currently pretty lost and pretty unsure if it's even possible to make a controller like this. My idea for this facade pattern and singleton is that you can have a static field in the frontend that any page can call so that it then becomes very easy to talk to the backend. I can't figure out if I need another design pattern for this or if this is pure anti-pattern. This MVC stuff is pretty new to me without spring so if anyone can point me in the right direction it would be nice :)
Aucun commentaire:
Enregistrer un commentaire