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!
1 Answer 1
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.
-
Thank you for your answer! I have thought about it, and said, why note make a separate model called
Roles
which associates with theUser Model
for flexibility. But like this, I will create all my models as common models instead of generalising them. Meaning, ifUndergrad
has a feature to view his courses with unique attributes and functions, and same goes forgraduate
, then I will just create one model calledView Courses Model
and list down both attributes and functions, and of course, associate it with theRole Model
. Am I getting this correct?Sobiaholic– Sobiaholic11/09/2013 10:22:37Commented Nov 9, 2013 at 10:22 -
@iMohammad: I don't quite follow you, but I also think that for the level of detail you are now asking at, it would be better to discuss it in front of an actual whiteboard. I would recommend you seek out some class mates and perhaps a professor/teacher/assistant and discuss your ideas with them.Bart van Ingen Schenau– Bart van Ingen Schenau11/09/2013 12:06:12Commented Nov 9, 2013 at 12:06
Explore related questions
See similar questions with these tags.