4
I’m building the class diagram of my project and I got a question at a certain point. In the project I create an instance of my Controller class in main and pass the reference (I know that in Java the passage is always by value, but when we pass the object we are passing a copy of the reference, so in general lines it ends up giving in the same, in most cases) this Controller instance for three Menus that are part of my project’s View.
public class Principal {
public static void main(String[] args) {
MeuController controller = new MeuController();
MenuProdutos menuProdutos = new MenuProdutos(controller);
MenuComprador menuComprador = new MenuComprador(controller);
MenuCompras menuCompras = new MenuCompras(controller);
//resto do código
}
}
From there I call several methods of these menus to perform registrations, sales purchases and etc. My question is: how to represent this in a class diagram? I cannot use a composition between my Main class (which contains the main) and the controller, as there is no controller attribute, although there is an instance of it in the main.
Also, I’m not sure what the relationship would be between my main class and the classes MenuProdutos
, MenuComprador
and MenuCompras
.
Also not sure what the relationship between the Menu classes and the controller would be, I thought it might be a composition, since I have controller-like attributes in each of them.