MVVM Pattern - Décisions clefs

Implementing the MVVM Pattern

http://msdn.microsoft.com/en-us/library/gg405484(v=pandp.40).aspx

Key Decisions

When you choose to use the MVVM pattern to construct your application, you will have to make certain design decisions that will be difficult to change later on. Generally, these decisions are application-wide and their consistent use throughout the application will improve developer and designer productivity. The following summarizes the most important decisions when implementing the MVVM pattern:
  • Decide on the approach to view and view model construction you will use. You need to decide if your application constructs the views or the view models first and whether to use a dependency injection container, such as Unity or MEF. You will usually want this to be consistent application-wide. For more information, see the section, "Construction and Wire-Up," in this chapter and the section "Advanced Construction and Wire-Up," in Chapter 6, "Advanced MVVM Scenarios."
  • Decide if you will expose commands from your view models as command methods or command objects. Command methods are simple to expose and can be invoked through behaviors in the view. Command objects can neatly encapsulate the command and enabled/disabled logic and can be invoked through behaviors or via the Command property on ButtonBase-derived controls. To make it easier on your developers and designers, it is a good idea to make this an application-wide choice. For more information, see the section, "Commands," in this chapter.
  • Decide how your view models and models will report errors to the view. Your models can either support IDataErrorInfo or, if using Silverlight, INotifyDataErrorInfo. Not all models may need to report error information, but for those that do, it is preferable to have a consistent approach for your developers. For more information, see the section, "Data Validation and Error Reporting," in this chapter.
  • Decide whether Microsoft Expression Blend design-time data support is important to your team. If you will use Expression Blend to design and maintain your UI and want to see design time data, make sure that your views and view models offer constructors that do not have parameters and that your views provide a design-time data context. Alternatively, consider using the design-time features provided by Microsoft Expression Blend using design-time attributes such as d:DataContext and d:DesignSource. For more information, see "Guidelines for Creating Designer Friendly Views" in Chapter 7, "Composing the User Interface."
Il faut impérativement se poser ces questions afin de trouver la bonne implémentation du Design Pattern MVVM en C#.NET.

Aucun commentaire:

Enregistrer un commentaire

Pour plus d'interactivité, n'hésitez pas à laisser votre commentaire.