Another back to basics post for reference material . I will follow this post with how to improve this basic pattern with .NET 4 objects. In building a real time news aggregator which requires a producer – consumer queue to provide up to the second news feeds for a trading engine, I have updated my [...]
Archive for the ‘Back to basics – C#’ Category
Simple Producer – Consumer Queue in .NET 4 part 1
Posted in Back to basics - C#, Threading, tagged c#, producer consumer, threading on December 29, 2011 | 1 Comment »
Basic UML diagrams
Posted in Back to basics - C#, tagged Design Patterns, diagramming, uml on October 18, 2011 | Leave a Comment »
UML has been around for a long time, but I don’t often use it in my projects. I find the whole subject of UML extremely dry. However, it is great for quickly sketching a design together for conversations as part of the Agile design process. It is a common language tool which the basics should [...]
Custom Exceptions in C#
Posted in Back to basics - C#, Error Handling, tagged c#, expected exceptions on March 5, 2011 | Leave a Comment »
C# Custom Exception handling There has been some discussion about whether or not to use custom exception handling at all, but call me old fashioned, I like to use custom exception as it better encapsulates known / expected problems, especially when writing service orientated architecture and you want to pass exceptions to the calling code. [...]
Setting up a Windows Service
Posted in Back to basics - C#, tagged installers, windows service on September 19, 2010 | Leave a Comment »
This is just a quick post to cover some of the schoolboy tasks when creating a Windows Service in C#. To create a windows service: Choose the project Windows Service Write code in OnStart and OnStop methods as appropriate In the InitializeComponent method, add the name of the service as it will appear in the [...]
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 [...]
Copying objects – Cloning
Posted in Back to basics - C#, tagged c#, cloning, deep clone, IClonable, serialization, shallow clone on April 28, 2010 | Leave a Comment »
Lets say we have some very simple objects such as these two classes: [Serializable] public class ClassA { public string StrA { get; set; } public ClassB B { get; set; } public ClassA Clone() { return (ClassA)MemberwiseClone(); } } and [Serializable] public class ClassB { public string StrB { get; set; } } There are three types of copying objects. These are [...]