I'm building the class diagram of my project and I was left with a question at one point. In the project I create an instance of my Controller class in main and step reference (I know that in Java the pass is always by value, but when we pass the object we are passing a copy of the reference, then in general lines it ends up in the same, in the most cases) from that Controller instance to three Menus that are part of the View in my project.
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 various methods of these menus for making records, buying sales and so on. My question is: how to represent this in a class diagram? I can not use a composition between my Main class (which contains main) and the controller, as there is no controller type attribute, although there is an instance of it in main. Also, I'm not sure which one would be the relationship between my main class and the MenuProdutos
, MenuComprador
and MenuCompras
classes.
I'm also not sure what the relationship between the Menu and controller classes would be, I thought it might be a composition, since I have controller-like attributes in each of them.