Posts about the C# language itself, including use, abuse and features.

Vocabulary Set

Saturday, March 16 2019 wordtutor-redux csharp

After creating VocabularyWord last time, our next step is to create VocabularySet, a container for many words.

Read more »

Vocabulary Word

Saturday, March 09 2019 wordtutor-redux csharp

To begin our little project, we need to create our initial project structure. Once that’s in place, we can create the first class from our application model - VocabularyWord.

Read more »

WordTutor Revisted

Saturday, March 02 2019 wordtutor-redux csharp

Let’s try an experiment - taking many of the things I’ve been blogging about over the past few years and applying them to the design and build of an actual application, with the source code published step by step.

Read more »

Converting a List to a Queue

Saturday, February 23 2019 priority-queues csharp

While chatting with a friend about this series, he made a suggestion about a significantly more effective way to implement the ToImmutablePriorityQueue extension method.

Read more »

Explicit Interfaces and Delegate Properties

Saturday, February 16 2019 csharp

When unit testing, it is common to create a fake implementation of an interface so that you can test another component in isolation. But how do you handle the case where each test needs a fake that does something different?

Read more »

Extension Methods

Saturday, January 19 2019 priority-queues csharp

Sometimes we’ll have an existing sequence of items that we want to prioritize - let’s explore a couple of simple extension methods that can make this easier.

Read more »

Generating Hash Codes

Saturday, January 12 2019 priority-queues csharp

Generating a hash code for an immutable priority queue introduces an unusual challenge: How do we generate a consistent hash code regardless of the order items are added to the queue?

Read more »

The Problem with Equality

Saturday, January 05 2019 priority-queues csharp

Did you spot the problem with the implementation of queue equality that we developed last time? As with the other bug we’ve encountered, this one stems from the comparison function we use.

Read more »

Queue Equality

Saturday, December 29 2018 priority-queues csharp

As is always important, we need to implement hashing and equality. But what does equality mean for a queue?

Read more »

Smarter Queue Enumeration

Saturday, December 22 2018 priority-queues csharp

I have a concern about the amount of debris created on the heap by the enumeration technique we used last time. Let’s explore an alternative approach and see how that compares.

Read more »

Queue Enumeration

Saturday, December 15 2018 priority-queues csharp

Sometimes our users might want to do something odd - like iterate the content of a queue without going to the hassle of dequeuing items one at a time. Fortunately, it’s not hard for us to support this.

Read more »

Queue Testing

Saturday, December 08 2018 priority-queues csharp

It’s vital that our priority queue returns items in the correct order, so we should write some unit tests to ensure that items are returned in the order desired. Fortunately, we can test this fairly easy using property tests.

Read more »

Creating Branching Nodes

Saturday, December 01 2018 priority-queues csharp

For a queue exceeding two items, our existing implementations are insufficient. We need another - a BranchingImmutablePriorityQueue<T>. Each of these nodes will combine two existing sub-queues with a head item to form a tree structure.

Read more »

Two Dual Item Queues

Saturday, November 24 2018 priority-queues csharp

Once we have a priority queue containing a single item, how do we handle enqueuing the next item onto the queue? The answer, of course, is buried in the code from from last time: we introduce the DualItemImmutablePriorityQueue<T>.

Read more »

Simple Queues

Saturday, November 17 2018 priority-queues csharp

As we did with our original immutable queue, we’ll define dedicated implementations of IImmutablePriorityQueue<T> for handling empty and single item queues.

Read more »

Enqueuing Values

Saturday, November 10 2018 priority-queues csharp

After exploring last time how to remove an item from a queue, let’s look at the slightly more complex case of adding items.

Read more »

Dequeuing Values

Saturday, November 03 2018 priority-queues csharp

Before we can start on the actual implementation of our immutable priority queue, we need to understand the algorithms we’re going to use. There are two different scenarios to consider - when we enqueue something onto the queue, and when we dequeue the head.

Read more »

Designing the External API

Saturday, October 27 2018 priority-queues csharp

As we did previously with our regular immutable queue, we should start by considering the design of our external interface - our API. How do we want our users to create and interact with our priority queue?

Read more »

Older posts

Introducing the Priority Queue  20 Oct 2018
A better approach to reflection  13 Oct 2018
Avoiding Magic Strings  06 Oct 2018
Capturing Validation Metadata  29 Sep 2018
Modelling Validation Metadata  22 Sep 2018
Validation Metadata  15 Sep 2018
Extending validation with warnings  08 Sep 2018
Validation recap  25 Aug 2018
Equality of validation  18 Aug 2018
Short-circuiting validation  11 Aug 2018
Aggregation of validation  04 Aug 2018
Recovery of validation types  28 Jul 2018
Basic validation  21 Jul 2018
Why we need better validation  07 Jul 2018
A question of struct performance  30 Jun 2018
Equality has Symmetry  17 Mar 2018
Type Miscellany  05 Mar 2017
Testing Immutable Types  25 Feb 2017
Factory Methods  18 Feb 2017
Queue Concatenation  11 Feb 2017
Complex Queues  04 Feb 2017
The Problem with the Simple Queue  28 Jan 2017
Enumeration of Queues  21 Jan 2017
Reversing Stacks  14 Jan 2017
Simple Queues  07 Jan 2017
Queues  30 Dec 2016
Stacks Miscellany  22 Dec 2016
Stack Equality  09 Dec 2016
Enumerating Stacks  03 Dec 2016
Stacks  19 Nov 2016
When (not) to use Var  16 Jul 2016
Semantic Types Redux  05 Jun 2016
Semantic Types in C#6  27 May 2016
Property Enhancements for C#  20 Dec 2015
Language Extensions for C#  19 May 2014
When should methods be Static?  09 Oct 2012
Of Method Naming and more  29 Sep 2012
Someone needs an intervention  16 Dec 2011
CallerInfo in C# 5  08 Dec 2011
Regions in C#  16 May 2011
Lambda expressions and Block syntax  15 Apr 2011
Parameter Attributes and more  05 Feb 2011
Elegant.Data  19 Oct 2010
Doing less with LINQ  30 Jun 2010
WCF and IList  28 May 2010
Specialist Classes  22 May 2010
Attack of the Lazy Coder  20 May 2010
A Discovery in Linq: Lookup  11 Feb 2010
Co- and Contra-Variance in .NET 3.5  15 Sep 2009
When to use Var  26 Mar 2009
Struct Weirdness  11 Feb 2009
Contravariance and Covariance at last  29 Oct 2008
Spec#  30 Apr 2008
Lambda Events  22 Mar 2008
No longer the C# we knew  21 Mar 2008
Rare C#  12 May 2007
Generics in .Net  28 Jan 2004