0

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

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 the User Model for flexibility. But like this, I will create all my models as common models instead of generalising them. Meaning, if Undergrad has a feature to view his courses with unique attributes and functions, and same goes for graduate, then I will just create one model called View Courses Model and list down both attributes and functions, and of course, associate it with the Role Model. Am I getting this correct? – Sobiaholic Nov 9 '13 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 Nov 9 '13 at 12:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.