Category Archives: Patterns

Presenting ValueType<T>

Here is a base class for some code that i have written once too many in my life: (In case you’re an early adaptor (.Net 4.0) you may want to use System.Tuple<T1> as base class) public class ValueType<T> : IComparable, … Continue reading

Posted in C#, Patterns | Leave a comment

Do we need an EventAggregator when we have an IOC container?

An Event Aggregator is an example of a Publish/Subscribe channel. A while ago i started wondering if we still need an Event Aggregator in our compisite applications if we have an IOC container that takes cares of dependency wiring. An … Continue reading

Posted in Information Technology, Patterns | Leave a comment

Creating series of elements

Lately i have done quite a bit of charting. Very often the X-axis is populated with a series of numbers or dates. This can be as simple as: (My very little DSL in Jeremy D. Miller Style) [Test] public void … Continue reading

Posted in C#, Patterns | Leave a comment

In case you really have to Append one array to another

Here is another problem i’ve seen people solve once too many: Append one array to another. STOP. Revisit the problem. Can’t you simply use List<T> and move on to solving actual business problems? In case you really can’t get rid … Continue reading

Posted in C#, Patterns | Leave a comment

About databinding and composite views

A couple of days ago i had a databound ItemsControl (collection of Model.Cell) which instantiated sub views (with their own viewmodel). <Grid.Resources> <DataTemplate x:Key="CellTemplate"> <views:CellView /> </DataTemplate> </Grid.Resources> <ItemsControl ItemTemplate="{StaticResource CellTemplate}" ItemsSource="{Binding Cells}" /> </Grid> Because each CellViewModel needs to … Continue reading

Posted in Patterns, Silverlight, WPF | Leave a comment

Exploring M-V-VM

A couple of years ago a collegue recommended Data Binding with Windows Forms 2.0: Programming Smart Client Data Applications with .NET and i noticed that my code started to gravitate towards an Model-View-ViewModel architecture. Due to shortcomings and painful experiences … Continue reading

Posted in Patterns, Silverlight, WPF | Leave a comment

Extension methods to improve readability

A common reason to take advantage of extension methods is to enhance readability (think fluent interfaces). My team uses the specification pattern regularly and in case a requirement says something like “if the player has reached level 10 a message … Continue reading

Posted in C#, Patterns | Leave a comment

Experimenting with ControlStateMachine and Fluent interfaces

A long time ago i read Build your own CAB series and recently i noticed that there is a wiki: Presentation Patterns Wiki! and it inspired me to experiment with state machines. Here are a couple of examples: controlStateMachine = … Continue reading

Posted in C#, Patterns, Windows Forms | 1 Comment

Strict mocks lead to overspecification

Here is an example that demonstrates how strick mocks lead to overspecification. Imagine that we are creating a simple screen in a Passive View architecture. The first feature that we implement is displaying the message “edit” when the user clicks … Continue reading

Posted in C#, Patterns | Comments Off

Refactoring EffectivityManager

A while ago i presented the EffectivityManager. Having used this class for a while i have decided to rename it to Temporal<T>. The implementation of IList<T> is not required anymore because a user is typically only interested in a specific … Continue reading

Posted in C#, Patterns | Leave a comment