In short, you want to create an MVC app that allows a user to identify a file; read the file; and then push the contents of that file into a database layer. Additionally, you want to treat the file handling routines as a Model.
View
- This will be your console application providing user input & feedback.
- User can select a file (via whatever means you pick)
- View will either call controller with file name / descriptor or leave it in a place where the controller can poll and pick it up. I'd have the View call the Controller, but I'm just pointing out other ways of doing it.
Controller
- Receives file name from View
- Calls
Model.FileServices
with file name
- Receives data returned from Model.FileServices, aka contents of file.
- Calls
Model.DBAccessLayer
to store data returned from Model.FileServices.
- Provide updates to View regarding transfer progress
Note, you'll end up with at least two Model modules. One for the FileServices
and one for the DBAccessLayer
.
So that's all well and good, but as file sizes increase then your system may not have enough memory to handle the entire file contents. There's a couple of options to resolve that issue.
Have the FileServices
implement a skip-take type call. This will allow you to pick up ### Byte blocks from the file and push to the DBA Model.
Implement a method within the Model.DBA
that essentially creates a stream between the FileServices
and the DBAccessLayer
. That would remove the Controller from acting as a traffic director, but it complicates the DBAccessLayer
instead.
Of the two options, I would prefer the first as I think it more appropriately assigns responsibilities for the associated actions.
1. How to model a patient ?
Your design, with its Account
, User
, and the different derivates of users are already a good start.
The Patient
could indeed be a special kind of User
. However, the Patient
is not a Diabetic
, Alzheimer
or Pregnant
. He/she has a pathology like Diabetes
or Alzheimer
, or a state like Pregnant
. He/she may even have several pathologies at the same time. Therefore I strongly recommend to go for an association of a Patient
with one or more Pathologies
. So use the principle of composition over inheritance.
As you came to this orientation by yourself, I can only confirm that you're one the good way.
How to model an Assistant ?
The assistant is proxy for a Patient
, at least in the business sense. He doesn't make an appointment for himself: he makes an appointment on behalf of a patient. Other patients may make their appointments themselves.
So the method of making an appointment should be offered by the Doctor
(or more precisely, by the doctor's schedule). But this doesn't oppose to also have a MakeAppointment()
on the Assistant
, that will forward the call to the relevant Doctor
.
And by the way, a patient also has a schedule: you shouldn't in principle make 2 appointments at the same time for the same patient. This brings le to a further approach: you could very well see MakeAppointment
as a "Transaction Script", that checks if schedule of doctor and of patient are free at a given time, then books the appointment on the doctor's schedule, then books it on the patient's schedule.
3. How to represent MVC ?
In fact it depends on the purpose of your UML diagram.
If it is a domain model, then it should only contain the domain objects (e.g. Patients, Doctors, Users) and no controllers or views, which would only make the model more difficult to understand.
However, if it is an implementation model, the you may show whatever class you need to build your software, including controllers and views.
More on role model
To come back on the role model, the issue discussed about Pathology
exist in reality also for other roles. For instance, a Doctor could as well be a patient, if he breaks his leg.
So one user could have several roles. This would similarly call for a composition design: the User
would bear the identity and each user could have several roles. You have then to think about which attributes are general and belong to the user, and which ones are specific to a role.
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
andGraduate
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
andGraduate
) 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.