I've seen rather a lot of this anti-pattern recently, to be explicit about what I mean, lets define this in terms of a WPF user control. Imagine the code behind file is nothing more than the auto generated code, but the XAML file contains the usual controls and bindings:
The user control is used in one or more data templates as follows:
The reason this is an anti-pattern is because it has introduced files into the solution which aren't required:
The two highlighted files are the user control files - XAML and code behind, the resources.xaml file contains the hosting data templates.
The reason why these aren't required is because the code behind for the user control is doing nothing, and therefore can be removed and the XAML can be moved into the hosting data template - now the view (MVVM) is no more than a data template:
And you can now see the user control files have been removed from the solution:
The user control is used in one or more data templates as follows:
The reason this is an anti-pattern is because it has introduced files into the solution which aren't required:
The two highlighted files are the user control files - XAML and code behind, the resources.xaml file contains the hosting data templates.
The reason why these aren't required is because the code behind for the user control is doing nothing, and therefore can be removed and the XAML can be moved into the hosting data template - now the view (MVVM) is no more than a data template:
And you can now see the user control files have been removed from the solution:
Comments
Post a Comment