I have just began learning UML, and I was wondering if a class could composite one way and aggregate the other way (if you understand what I mean). Let's make an example:
Maingui.java:
private controller;
public Maingui() {
controller = new Controller(this);
}
Controller.java
private maingui;
public Controller(Maingui gui) {
maingui = gui;
doSomethingWithMainGui();
}
private void doSomethingWithMainGui() {
maingui.doSomeThing();
}
Is this the correct way to show the association?
It's correct way to show assocation, but it's example of bad style app architecture. One of principles of good style architecture is loose coupling. You can read here about it: What is the difference between loose coupling and tight coupling in the object oriented paradigm?