Please first read Part one of the simple producer – consumer queue in .net4. In part 1 we defined a standard producer – consumer queue, however, there was nothing that particularly made this stand out from a queue written in a previous version of .Net. In this post, I am going to upgrade the queue [...]
Archive for the ‘Design Patterns’ Category
Simple Producer – Consumer Queue in .NET 4 part 2
Posted in 2. Application Development, Design Patterns, Threading, tagged .NET4, c#, producer consumer, threading on January 8, 2012 | Leave a Comment »
Unit testing for managed memory leakage
Posted in Design Patterns, Memory Management, Problems and Solutions, TDD, Threading, tagged c#, garbage collection, GC - Memory Management, jet brains, performance, unit testing, weak references on December 31, 2011 | Leave a Comment »
It might seem a strange thing to do. Firstly can there be managed memory leakage? And secondly how can you unit test for this? I’ll put this into context and then all will become clear. I came across this interesting problem recently when playing around with a set of streaming real time data and attaching [...]
Building a news aggregator module for a trading platform –The architecture
Posted in 1. Financial, 2. Application Development, Agile, Architecture, Design Patterns, Problems and Solutions, Threading, Traders Tools, World View, WPF, tagged agile, architecture, c#, news aggregator, producer consumer, software design, WPF on December 16, 2011 | Leave a Comment »
In my recent post introducing the news aggregator I detailed what we are currently building. In this post, I will discuss some very high level architecture and some considerations around how to build the application. My first draft at architecture is to just get the different functional parts of the program identified. Then later we [...]
Making WPF Converters easier to use
Posted in Design Patterns, Problems and Solutions, WPF, tagged Adapter, IMultivalueConverter, IValueConverter, WPF on December 5, 2011 | Leave a Comment »
When binding data to WPF controls it is good practice to use a IValueConverter or IMultiValueConverter or use the adaptor pattern which is what I do for the equivalent when using MVC for the web, to change the values from your domain objects to something you can bind to which makes sense for the Gui [...]
Best practices for writing HTML forms
Posted in Design Patterns, HTML5, tagged best practices, css, forms, html5, tables on October 11, 2011 | Leave a Comment »
Over the years I have changed the style of my HTML coding considerably. Back in the day (pre 2000) every one including me coded everything using tables. Tables rocked and made it quickly possible to layout pages. Pages were mostly cut up images straight from Photoshop. It was the web developer’s job to create a [...]
Setting up Castle Windsor IOC for web applications
Posted in Architecture, Castle Windsor, Design Patterns, IOC, NHibernate, ORM, TDD, tagged c#, Castle Windsor, Design Patterns, domain, IOC, loosely coupled, Mapping files, NHibernate, ORM, separation of concerns, test driven design, web architecture on September 27, 2010 | 2 Comments »
I recently wrote a post about how to set up CW’s IOC container for applications. This post covered the most basic implementation to get an IOC container up and running. It is now time to cover a proper architecture for using IOC specifically for web applications / sites. The main problem with the previous implementation [...]
Testing MS asp.net code behind
Posted in Architecture, Castle Windsor, Design Patterns, TDD, tagged Castle Windsor, Design Patterns, IOC, loosely coupled, separation of concerns, test driven design, web architecture on August 22, 2010 | 1 Comment »
Testing Microsoft’s web forms (asp.net) UI. Microsoft’s web form architecture is not particularly good for testing. The event driven architecture of ‘code behind’ means lots of logic gets stored in C# code that is tightly bound to the HTML code. This means you can’t write purely C# unit tests for it. The best solution is [...]
Object Equality
Posted in Back to basics - C#, Design Patterns, TDD, tagged Design Patterns, gethashcode, overriding equals, test driven design on May 2, 2010 | 1 Comment »
Whilst developing applications and especially while unit testing it is often required to test whether an object t is equal to some other object of the same type. It is almost always a value type comparison that is required. This means we need to check to see if the fields on the objects match and [...]
Dispose Pattern
Posted in Architecture, Design Patterns, tagged com interop in .net, Design Patterns, Dispose Pattern, resource management on April 16, 2010 | 1 Comment »
I had an interview the other day and thought I would write abut one of the questions I had. It involved releasing references to COM objects in .NET. The pattern to do this is unsurprisingly called the Dispose pattern. The problems with using COM components in managed code are as follows: 1. Developers can accidentally [...]
Decorator Pattern
Posted in Architecture, Design Patterns, tagged code reuse, decorator pattern, Design Patterns, web architecture on April 15, 2010 | Leave a Comment »
This is the second in the series of design patterns. The first post might have been a little verbose so I thought I’d liven this one up a bit with a good old fashioned class diagram and some actual code! I used the decorator pattern recently on the advert booking project. The scenario is this: [...]