csharp

Reading F#

A tweet about some C# code rewritten in F# got me interested yesterday. If you know a little F# it’s easy get sucked into thinking that having much fewer lines of code, and less noise generally makes F# code automatically better, cleaner, easier to read than C#. But, of course, that’s only true for people who know enough F# to read it. When I see very smart C# devs unable to decipher what the F# code is doing, that gets me very interested.

Continue reading

Unit Testing Events And Callbacks In C#

The Problem When you want to unit test a method it’s usually pretty simple. Call the method, pass it it’s parameters and assert against it’s return value, or some other property of the object that may have changed. What happens when a method doesn’t return a value, or update some property? What happens when it leads (perhaps after some delay) to an event firing, or a callback getting called? Events firing and callbacks getting called are very similar, but subtly different, so I’ll cover them both.

Continue reading

C# Is Too Damn Noisy

I am growing increasingly frustrated with C#. I think the reason for that may be my exposure to languages like F#. In many ways my feelings for C# are quite similar to feelings I had about VB.Net when I was first exposed to C#. It’s taken me a while to figure out what it is that I find irritating about C# and I think I’m ready to call it. The problem with C# is exactly the same problem I had with VB.

Continue reading

I is for Interface

Back in 1995 I sat in a large ballroom to listen to politicians from the North and South of Ireland talk about the peace process, which at that time was far from a sure thing. A story, told by one of the Unionists stuck in my head. He told of how he had been involved in selling a ceasefire to loyalist paramilitaries and one of the questions that he was faced with was.

Continue reading

The Anagrams Kata

The following is my C# implementation of the Anagrams Kata as described on cyber-dojo.com Write a program to generate all potential anagrams of an input string. For example, the potential anagrams of “biro” are biro bior brio broi boir bori ibro ibor irbo irob iobr iorb rbio rboi ribo riob roib robi obir obri oibr oirb orbi orib Let’s write a test. [Test] public void NoCharacters() { var expected = new List<string> {""}; Assert.

Continue reading

Fluent Mocking

Here’s a scenario (for once not a hypothetical scenario, this is a real system I worked on). I was building a wizard based app. To be more accurate I was building lots of wizard based apps. After a couple of wizards the functionality became clear and I extracted it to it’s own framework. My apps could then focus on actual bread and butter functionality. Two of the objects in my framework are ‘Wizard’ and ‘WizardStep’.

Continue reading