Best architectural approach for a simple MVVM program #16200
-
Hi, I am wondering if anyone can offer any tips or insights for a design approach for a program I am developing. I am developing a desktop application and using the MVVM approach. I worked on some of the Avalonia beginner MVVM samples to understand it better. Here is the background of my app: This application is controlling a piece of test equipment. The equipment is a simple switch box for switching/selecting RF signals. I believe the app should be fairly simple. The main purpose is to allow the user to select the state/position of the various switches that are in the box. The app should also display information about the box, such as serial number, current firmware version, model number, etc... I believe this is a simple app, so I am not sure if I need to have a model which is separate from the ViewModel? So far I have taken the following approach
QUESTIONS:
Sorry if this is many questions wrapped into a single post, any suggestions or insights would be appreciated. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
I typically only make Models when:
Otherwise, I put the logic into a service class (eg. a service to query / control RF devices), call it directly from the ViewModel, and assign results directly to ViewModel state. Having a real Model layer means more indirection and that adds more pain. Sometimes with little to no value, especially for small apps with a solo dev or very small team. |
Beta Was this translation helpful? Give feedback.
-
You can check out https://github.com/stevemonaco/AvaloniaNavigationDemo as an example of how to use On service classes, it depends on what you need to share. There are several approaches via DI:
It gets trickier when the state is not global. Messaging can help communicate across decoupled components, especially when high level app events occur. |
Beta Was this translation helpful? Give feedback.
I typically only make Models when:
Otherwise, I put the logic into a service class (eg. a service to query / control RF devices), call it directly from the ViewModel, and assign results directly to ViewModel state.
Having a real Model layer means more indirection and that adds more pain. Sometimes with little to no value, especially for small apps with a solo dev or very small team.