I’m creating an app that allows users to create, list and edit customers.
Would you create a separate view models for listing entites; adding updating deleting entites or one viewmodel with an enumeration passed to establish functionality?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I would create a separate viewModel for each functionality.
In general I dislike to have an enumeration to establish functionality; it force you to have many “if” in your code, that becomes complex and difficult to understand. In each context I try to avoid this using different technique depending on the context: ViewModels in the application layer of a WPF application, the State pattern when the different behaviour is dependant from some sort of state, the Strategy pattern when I have to inject the behaviour at runtime or I have to reutilize the behaviour in different classes, and so on …
Sometimes you need to mix this technique: for example you can have a ViewModel to edit customer that has a complex behaviour implemented by a state machine.