Published by on March 20th, 2012 3:39 pm under Code
Getting Started: An ASP.NET MVC site that lists customers Download all the code here. This section is the vanilla MVC to set the stage for talking about AJAX and JSON payloads later on. This should all be very familiar to ASP.NET MVC developers. 1. First, wel add a very simple customer model. public class Customer... read more
In case you aren’t familiar with StyleCop, it is a C# source code analyzer that “enforces a set of style and consistency rules”. I applaud StyleCop’s goals toward improving code quality, readability, maintainability, and preventing reformatting check in wars between developers. However, when the entire set of rules are enabled StyleCop has a significant detrimental... read more
Giving meaningful names to unit tests is critically important to quality unit tests. Unit tests classes often contain a large set of test methods and it can be challenging to distinguish from between tests because of the small permutations of the condition, the action, or the result. I was clued in to the When/Then naming... read more
Published by on October 19th, 2011 5:54 am under Code
Revision: Behavior problems In my original post I provided a behavior (ViewModelBehavior) for provding a view model for the given DataContext. The behavior saved away the original DataContext as the model, set DataContext of the AssociatedObject to the view model, and passed the model to the view model. This worked in 90% of the basic... read more
Published by on October 12th, 2011 8:33 am under Code
M-V-VM encourages POCO view models M-V-VM is one of the design patterns that help separate concerns between presentation and data: The model is concerned with data and knows nothing of the view or view model. The view is concerned with presentation. It only knows about the view model or model through data binding. The view... read more
A better M-V-VM library There are several existing libraries that support the Model-View-ViewModel (M-V-VM) pattern. They each have some nice features. However, I didn’t find any that were just M-V-VM. Some required me to fundamentally restructure my XAML. Others required me to use dependency injection or implement a view model locator pattern. A few required... read more
As part of the talk I gave on Modularity with Prism today, I created a very small modular application. The Simplest Modular Application This WPF application allow you to type different commands into a text box and see the result in a textbox below. The app has just has 1 module – the MathModule –... read more
Published by on June 29th, 2011 12:04 am under Code
Yesterday I got the opportunity to talk about Unit Testing and MOQ at a WPF/Prism conference in Boise put on by Karl Shifflett (Microsoft). I had a great time and appreciate how the attendees were so engaged in the talk even at the end of day. Unit Testing Scenarios I covered the following unit testing... read more
Published by on March 15th, 2011 8:35 am under Code
WPF Support WPF provides excellent support for shortcut keys: The InputBinding class supports Key, Mouse, and recently Touch gestures. An InputBinding can be associated with any UIElement using the InputBindings property. Custom controls that handle RoutedCommands can associate InputBindings using the CommandManager.RegisterClassInputBinding. The CommandManager provides tunneling and bubbling of the commands allowing any control with a... read more
Published by on September 3rd, 2010 6:50 am under Technology
I’ve been working heavily with Managed Extensibility Framework (MEF) as part of Prism v4. Through this effort (and by regularly pestering Glenn Block with questions), I’ve compiled some guidelines that I find useful. I’ve based my guidelines on a style I first saw in ‘Effective C++’ by Scott Meyers. I like his use of the word... read more