I would like to hear what all relationships exists here. I assume that here exists relationships like dependency and aggregation with 1-1 multiplicity?
public class Main {
public Main() {
Model model = new Model();
View view = new View();
Controller controller = new Controller(view, model);
}
public static void main(String[] args) {
new Main();
}
}
public class Controller {
private Model model;
private View view;
public Controller(Model model, View view) {
this.model = model;
this.view = view;
}
}
public class Model { ... }
public class View { ... }
It's simple, there is no need here for reverse engineering (constructing the model from code).
Main
has three associations: one with Model
, one with View
and one with Controller
, while Controller
has two associations: one with Model
and one with View
.
Notice that there is no need for the associations Main-Model
and Main-View
because they can be derived via main.controller.model
and main.controller.view
.
The association Main-Controller
(as well as Main-Model
and Main-View
) can be viewed/modeled as a composition, since a main program instance (a process) is composed of a controller instance, which is bundled with a model and a view instance. All three compositions come with a lifecylce dependency: any model, view and controller instance existentially depends on its main aggregate instance.