1

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:

My 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?

Mr.Turtle
  • 2,950
  • 6
  • 28
  • 46

1 Answers1

0

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?

Community
  • 1
  • 1
Cortwave
  • 4,747
  • 2
  • 25
  • 42
  • 1
    I'm seeing a logical disconnect here, but then I fell on my head as a child. How can two objects each be aggregates of each other, let alone composed of each other? – BobRodes Dec 08 '14 at 20:47