I am currently working on a bigger WinForms project. I used to program small applications using WinForms that had a maximum of ~20 different windows.
Now I am facing a bigger project and want to adapt to that by overthinking my approach to that.
I have read about MVVM and MVC and some variations.
Speaking of variations: I found so many variations, that I have no idea which implementation they originated from.
My Idea is that it has:
-easily scalability
-clear seperation of concerns (SoC)
-an intuitive way of usage
Some side-notes on this project:
-Hotkey-driven navigation (every view can have multiple hotkeys to navigate to other views)
-Fast response time required (the client does not like to wait for a query to finish longer than 1 second.)
Below you will see my current idea of how to use a pattern.
I am very thankful for criticism and/or tips on this.
Also I would be very thankful to hear your suggestions on how to use this pattern and if any traps exists how to avoid them.
Thank you in advance :)
What I have tried:
So far I have designed the following pattern as an approach:
Classes:
View
void SetViewModel(ViewModel viewmodel);
void Clear();
Thoughts:
The View only has to accept a ViewModel class to display.
All logic in the view is for registering key events and button clicks etc.
If something like that happens a event is fired or a command redirected to the Controller.
Controller
void AddView(View view);
void RemoveView(View view);
void SetModel(Model model);
void SetViewModel(ViewModel viewmodel);
Thoughts:
My controller will contain all decision-relevant logic. (example: If button X is clicked on View - Open new View)
It will accept views (one or many) and update every View.
ViewModel
event PropertyChangedEventHandler PropertyChanged;
T Get<T>(string property);
void Set<T>(string property, T value);
Model
event PropertyChangedEventHandler PropertyChanged;
T Get<T>(string property);
void Set<T>(string property, T value);
Thoughts:
Model and ViewModel are almost similar.
They contain the values of the entity and fire events when a property changes.
Converter<TVM, TM>
TM ConvertToModel(TVM viewmodel);
TVM ConvertToViewModel(TM model);
Thoughts:
My Converters will be responsible on converting models from ViewModel to Model and back. They will need to handle view-relevant conversions and formatting specific things.
Conclusion:
I am unsure how to identify implementation traps and possible faulty design choices beforehand and require some guidance on how to approach a big project with a neat pattern to follow.