0
votes

It is possible (recommended) create UML diagram of an MVC action including the form fields of a web system?

For example, create a UML these steps:

Controller: TestController Action: actionIndex

steps:

Upload POST data and validator model

if loaded and validated: save if not loaded or not validated: Load view

In view, we have a form with several fields, where one of the fields is a radio button list, where you have two options: "yes" and "no." If set to "yes" displays another field that is hidden.

Is possible, but it is recommended to do? If advised to do, like an example.

2
What purpose would such a UML diagram serve? No purpose, no diagram.Robert Harvey

2 Answers

1
votes

Things in UML (UML elements) belong to one of four categories (The UML user guide):

  • Structural things
  • Behavioral things
  • Grouping things
  • Annotational things

MVC is a design pattern defining structural features. You intend to model behavioural features: a sequence (not the UML meaning) of operations.

I think the most appropriate diagram to describe your system would be an interaction diagram: the activity diagram. But unfortunately this would not show the structural aspect of the your MVC system. Using a sequence diagram (another interaction diagram) would allow you to model the involved objects and by the way induce structural information. The choice depends of your software development methodology : using a sequence diagram when starting a project is rarely advisable (objects and classes are usually defined in latest stages).

UML will not allow you to represent UI components because it is a language for modeling. There is another OMG language : IFML for flows of interactions and UIs. But it would not allow you to model a form. It is derived from another (non-standard) language : WebML which has an interesting feature called the hypertext model (it is not part of IFML until now) but this would not help you on your form anyway. For that you should use a sketching tool (for example Pencil sketching).

-1
votes

Is it recommended to create a UML diagram of an MVC action including the form fields of a web system?

A true MVC approach is based on model classes, which contain the entire validation logic and can be modeled with a UML class diagram (see my CodeProject article Integrity Constraints and Data Validation). The UI ("view") for CRUD operations is based on this model. For instance, a form is typically bound to a model class, and form fields are bound to properties of that model class, and they get their validation logic (e.g., being mandatory) from the definition of this model property.

Therefore, when you make a class diagram for your model classes, you have also implicitly modeled large parts of your "views". And controllers are just an afterthought for connecting "views" with model classes.