C# 7 is due to be released along with Visual Studio 2017, which is currently available as an “RC” release
. I had previously regarded it as a thoroughly unexciting “meh” release, for – beyond new syntactic tuple features – the changes were minor and not really worth getting excited (or even angry, depressed etc) about. Then just before that RC release, the language team made a change to the way the
feature works. And suddenly that all changed. This minor feature has become a significant change to the language. And many people aren’t at all happy about it.
Continue reading “C# 7, “out var” and changing variable scope”
If you are a C# programmer, the chances are, you use an imperative approach to coding. You may have heard of the declarative (or functional) programming approach offered by F#, but are you aware that the same approach can be used in C# too? This article attempts to show how C# can be used in this way, and to explain why it often leads to shorter, simpler solutions to any programming requirements.
Continue reading “Why declarative programming is often better than imperative, even in C#”
The .NET framework has a lot classes, with a lot of methods. So many in fact that when certain, obvious ones are missing, it’s a puzzle as to why. One such missing feature is a
method for strings. Taking a collection of characters and reversing them is easy; so why is it missing?
As I wanted such a method, and didn’t want to burden the library I was writing with a disconnected feature, I created the
ReversedString nuget package, which supplied it. Job done. Still, why isn’t it included in the standard framework? Experimenting with tests led me to a possible reason. Continue reading “When is a reversed string, not a reversed string?”
A few days ago, version 2.0.0 of Succinc<T> was released via nuget
. As Succinc<T> follows the conventions of semantic versioning, the switch from 1.x to 2.0 is a clue that the release includes breaking changes. In addition though, a number of new features have been added. This release notes describes both the breaking changes and new features. Continue reading “Succinc<T> v2.0.0 release notes”
Many programming languages allowing optional trailing commas when declaring collections of data. Some argue it’s good practice; others (including me) that it’s bad. So why are they allowed, why do some swear by them, and why do I argue against them? Continue reading “Trailing commas: good or bad practice? (TL;DR: it’s bad)”
Arnolyzer is a Roslyn-based analyzer for Visual Studio 2015 that provides a set of compiler rules that encourage modern, functional-orientated, coding standards in C# 6. Pure functions; no inheritance; no global state; immutable data classes and variables; and short, concise sections of code. Continue reading “Arnolyzer: adding clean-code static analysis to C# in VS2015”
In part 2 of this series
, we looked at contravariance, which is a special case of generic variance, for interfaces that only allow instances of
, to be passed in, either via method parameters or through property setters (though good code will not contain the latter, of course). It’s perhaps no surprise that covariance is the opposite. Only when
allows instances of
to be passed out (either via method returns, or property getters), can that interface be covariant. Continue reading “Generic variance in C#, part 3 — Covariance”
Contravariance is perhaps the hardest of the three types of generic variance to understand (at least I found it so). This article hopefully takes the reader through two examples of its use to explain what it is, before showing how it’s used for real in the .NET Framework.
This is part 2 of a three part series on generic variance in C#. Part 1, covers invariance. The final part, covers covariance.
Continue reading “Generic variance in C#, part 2 — Contravariance”
C#’s generic types are, by default, invariant. Special cases of covariant and contravariant can be defined though. So what does that previous gobbledygook even mean? Hopefully this three-part article will help explain these three terms, and why they even exist in the first place.
The second part of this series, looks at what is probably the least well understood of the three terms: contravariance. If you feel you understand the other two terms, feel free to jump straight to that part therefore. The third, and last, part, looks at covariance and finishes with a summary of the difference between the three. But first, we start at the beginning: invariance.
Continue reading “Generic variance in C#, part 1 — Invariance”
Many years ago, back when OO was a new, exciting idea that appeared to offer a panacea solution to developing applications, Martin Fowler wrote an article entitled “Anemic Domain Model” (ADM), in which he argued that separating data from functionality, within the OO paradigm, is an anti pattern.
Twelve years later, things have moved on quite a bit. Many now recognise the benefits of such a split; yet some still, near-religiously, stick to the idea that the anaemic data model is somehow “not real OO”. Part of this stems from the (presumably deliberate) use of a negative term to describe that separation approach. It’s therefore time to fight back with new definition of the terms “RDM” and “ADM”, to help move us away from the antiquated view that separating data from functionality is an anti-pattern. It’s the RDM that has been shown to be the real bad design approach.
Continue reading “The Rotten Domain Model is dead; long live the Abstracted Domain Model”
Recently, I heard of a job interview in which the applicant claimed on their CV that they worked for a “strict agile” company. At the time, I thought of this as a good thing. However, reflecting upon it, it strikes me as yet another example of a worrying trend around agile practices, namely treating only specific ways of working as being agile. “Strict agile” is really an oxymoron: it’s another sign that we are witnessing the death of agile through “processification”, or the setting in stone as to what “agile” can be. Continue reading “The slow death of agile”