Search code examples
model-view-controllerumlclass-diagram

UML MVC pattern List class use


When designing a class diagram for a theoretical MVC-Pattern-based system, is it best to use List classes?

For example:

With List class:

diag 1

Without list class:

diag 2

I personally feel the latter is a better approach due to less code duplication, is there a better approach to this?


Solution

  • I don't think there is a need for a list class. Your controller can hold all references to the model.

    Regardless of that, your UML models have a problem: in both cases you have an attribute customers:Customer[] and an composition link. This means that you have TWO references from the controller (or list) to the model. Either remove the attribute or the link.