C# needs to allow us to write code in a more functional, immutable style

Posted on Updated on

Since C# 6.0 is now feature-locked (and I can’t wait) it’s time to start talking about something that might be in the next version, assumedly called C# 7.0.

The big feature for me would be to get C# to help us write immutable code. That means they need to make it easy to write immutable classes (see my last post on Record types) and immutable local variables too.

I propose the following syntax:

Read the rest of this entry »

My proposed syntax for record types in C#

Posted on Updated on

With the impending release of C# 6.0 and all its new features, I have been thinking about what might come in the next version of C# (v7.0, I’m guessing). There has been talk in the Roslyn forums about things such as pattern matching and record types (the latter being especially important since the primary constructors feature was dropped from C# 6.0).

Below is a quick sketch of how I think record classes should work in C#. You can probably tell that I spend a lot of time programming functionally, because I’ve included a number of syntax features here to make immutability a very easy option.

Read the rest of this entry »

London photowalk

Posted on Updated on

Last week I went on a photowalk with friends. The idea is that people with a shared interest in photography meet up and walk along a pre-prepared path, taking pictures as they go. The walk started at the Hays Galleria near London Bridge and we continued through the Inner London Pool starting on the South side of the river and travelling over to the North side and back again.

Along the way we took in some of London’s finest landmarks through the back streets finding views of London Bridge, the Shard, the Tower of London, Monument and more. This one was part of the Kelby Worldwide Walks and there was a competition to go with it.

I have included a gallery of the shots I took (and decided to keep), and the photo I entered into the competition too.

An introduction to F#: Part 1

Posted on Updated on

A few days ago I ran an introduction to F# course for colleagues at work. The idea of the course was to explain the basics of F# including syntax, programming style and the FSI window, as well as to get people excited. I didn’t correctly judge how long the presentation would take (people were asking lots of questions as I went, which is good!), so I ended up splitting it up into two parts. Here I am publishing a rough written copy of the presentation, compiled from my notes that I worked from as I talked, for you to peruse. It’s somewhat rough, but for those who were there it should serve as a reminder. Next time we will talk through some worked examples of Fizzbuzz & fizzbuzzbaz, we will cover types (classes, structs, interfaces, enums, records, units of measure and discriminated unions). We will also go through some application design, such as: MVC, DDD, CQRS, WTFBBQ.

Read the rest of this entry »

Classic mashup: An FSharp coding dojo

Posted on Updated on

Yesterday I attended the FSharp Dojo: Picasquez and Velasso at Skills Matter in London.

This dojo is all about manipulating images and creating mashups, like this:

Classic mashup image

Read the rest of this entry »

Finding overlapping rectangles

Posted on Updated on

This is a classic quick programming puzzle: write a function that, given two rectangles, will determine if the triangles overlap. I found this puzzle over on http://leetcode.com/2011/05/determine-if-two-rectangles-overlap.html, and thought it was worth talking about because the solution is wrong, and it was interesting to me because it shows how thinking about a domain can influence your implementation of behaviour.

The mistake made by the original author is with one of the assumptions / interpretations made during their reasoning process. They said “when two rectangles overlap, one rectangle’s corner point(s) must [be contained within] the other rectangle”. This appears reasonable, given the example below:

Read the rest of this entry »

Programming interview questions

Posted on Updated on

At my last company I was a team lead and, as such, was one of those responsible for interviewing new candidates. Although I didn’t enjoy the process much, I did become interested in the sorts of technical questions / exercises we could set to get a good judge of a candidate’s abilities.

Developer interviews typically cross a number of disciplines (often arranged in stages) that may include:

  1. a CV / résumé screening
  2. a telephone interview
  3. face-to-face questions and answers
  4. a technical exercise or written test to be done at home, or to be done in front of the interviewers

Read the rest of this entry »