Mvc – Making Class Diagram for MVC Pattern Project

Architectureclass-diagramcodeigniterdesignmvc

I have a question about making a class diagram for an MVC based college senior project.

If we have 2 actors of users in my system, lets say Undergrad and Graduate students are the children of abstract class called User. (Generalisation)

Each actor has his own features.

My question, in such case, do we need to have these two actors in separate classes which inherits from the abstract class User? even though, I'm going to implement them as roles using one Model called User Model ?

I think you can see my confusion here. I code using MVC pattern, but I've never made a class diagram for this pattern.
Thank you in advance!

Best Answer

A class diagram should work as a graphical representation of the code you are intending to write. You can leave out implementation details that are not important for understanding the design of the code, but the elements that you do show in a class diagram should also be directly represented in the code.

This means that if your ' User Model' consists of one class that fills the roles of both the Undergrad and Graduate users, then it should also be depicted as one class in a class diagram.
But given your description, I would expect the model to contain at least two classes (Undergrad and Graduate) with a common interface or abstract base class.

Note that the fact that there are only three components to MVC does not mean that you can only show three classes in a class diagram. In a typical class diagram of an MVC application, the use of MVC may not even be obvious to the untrained eye. For example, it can be hidden in the naming of the classes and how they are grouped in the drawing. If you want to make the MVC pattern obvious in your class diagram, I would recommend using colours to indicate the classes that together form the Model, View or Controller parts of the MVC pattern.

Related Topic