Using System.Text.Json, with and without Reflection. This article is part of a short series of articles about serialization with and without Reflection. In this instalment I'll explore some options for serializing JSON with C# using the API built into .NET: System.Text.J … | Continue reading
Using System.Text.Json, with and without Reflection. This article is part of a short series of articles about serialization with and without Reflection. In this instalment I'll explore some options for serializing JSON with F# using the API built into .NET: System.Text.J … | Continue reading
Using Aeason, with and without generics. This article is part of a short series of articles about serialization with and without Reflection. In this instalment I'll explore some options for serializing JSON using Aeson. The source code is available on GitHub. … | Continue reading
An investigation of alternatives. I recently wrote a tweet that caused more responses than usual: "A decade ago, I used .NET Reflection so often that I know most the the API by heart. "Since then, I've learned better ways to solve my problem … | Continue reading
Or, rather: Try not to. A few months ago I visited a customer and as the day was winding down we got to talk more informally. One of the architects mentioned, in an almost off-hand manner, "we've embarked on a SAFe journey..." "Yes..?" I responded, hoping that m … | Continue reading
A refactoring example. When I introduce the Fake Object testing pattern to people, a common concern is the maintenance burden of it. The point of the pattern is that you write some 'working' code only for test purposes. At a glance, it seems as though it'd be more work t … | Continue reading
Noun. Game in which the goal is to minimise cyclomatic complexity. Cyclomatic complexity (CC) is a rare code metric since it can be actually useful. In general, it's a good idea to minimise it as much as possible. In short, CC measures looping and branching in c … | Continue reading
Contracts of Fake Objects can be described by properties. The first time I tried my hand with the CQRS Booking kata, I abandoned it after 45 minutes because I found that I had little to learn from it. After all, I've already done umpteen variations of (restaurant) bookin … | Continue reading
A raw port of the previous F# demo code. This article is part of a short article series on applicative validation with a twist. The twist is that validation, when it fails, should return not only a list of error messages; it should also retain that part of the input that … | Continue reading
Persistence concerns second. A few weeks ago, I published an article with the title Do ORMs reduce the need for mapping? Not surprisingly, this elicited more than one reaction. In this article, I'll respond to a particular kind of reaction. First, however, I'd l … | Continue reading
Static types are useful, but have limitations. Regular readers of this blog may have noticed that I like static type systems. Not the kind of static types offered by C, which strikes me as mostly being able to distinguish between way too many types of integers and pointe … | Continue reading
Ultimately, it's more about programming than food. The Sandwich was named after John Montagu, 4th Earl of Sandwich because of his fondness for this kind of food. As popular story has it, he found it practical because it enabled him to eat without greasing the cards he of … | Continue reading
AKA Framework Whac-A-Mole, Library Whac-A-Mole. I have now three times used the name Whac-A-Mole about a particular kind of relationship that may evolve with some dependencies. According to the rule of three, I can now extract the explanation to a separate article. This … | Continue reading
A ploeh mystery. I was recently playing around with the example code from my book Code That Fits in Your Head, refactoring the Table class to use a predicative NaturalNumber wrapper to represent a table's seating capacity. Originally, the Table constructor and c … | Continue reading
With some Entity Framework examples in C#. In a recent comment, a reader asked me to expand on my position on object-relational mappers (ORMs), which is that I'm not a fan: I consider ORMs a waste of time: they create more problems than they solve. … | Continue reading
An experience report. In my book Code That Fits in Your Head (CTFiYH) I write in the last chapter: If you've looked at the book's sample code base, you may have noticed that it looks disconcertingly monolithic. If you consider the full code base that inclu … | Continue reading
Test-driven development in C#. A customer hired me to swing by to demonstrate test-driven development and tactical Git. To make things interesting, we agreed that they'd give me a kata at the beginning of the session. I didn't know which problem they'd give me, so I thou … | Continue reading
With simple and easy-to-understand examples in F# and Haskell. Eve Ragins recently published an article called Why you should use truth tables in your job. It's a good article. You should read it. In it, she outlines how creating a Truth Table can help you smoke … | Continue reading
A simple C# example. A reader recently wrote me about my 2013 article Mocks for Commands, Stubs for Queries, commenting that the 'final' code looks suspect. Since it looks like the following, that's hardly an overstatement. public User GetUser(int userId) { … | Continue reading
The universal API for generic non-empty collections, with examples in C# and Haskell. This article is part of an article series about catamorphisms. A catamorphism is a universal abstraction that describes how to digest a data structure into a potentially more compact va … | Continue reading
Some thoughts on TDD related to integration and systems testing. My recent article Works on most machines elicited some responses. Upon reflection, it seems that most of the responses relate to the top of the Test Pyramid. While I don't have an one-shot solution … | Continue reading
A rant, with some examples. I've been a software user for thirty years. My first PC was DOS-based. In my first job, I used OS/2, in the next, Windows 3.11, NT, and later incarnations of Windows. I wrote my first web sites in Arachnophilia, and my first … | Continue reading
TDD encourages deployment flexibility. Functional programming also helps. Recently several of the podcasts I subscribe to have had episodes about various container technologies, of which Kubernetes dominates. I tune out of such content, since it has nothing to do with me … | Continue reading
A solution in search of a problem? I was recently listening to a podcast episode where the guest (among other things) enthused about how advances in large language models mean that you can now get these systems to write XML doc comments. You know, these things: … | Continue reading
On separating preconditions from business rules. My recent article Validation and business rules elicited this question: "Regarding validation should be pure function, lets have user registration as an example, is checking the email address uniqueness a va … | Continue reading
A definition of validation as distinguished from business rules. This article suggests a definition of validation in software development. A definition, not the definition. It presents how I currently distinguish between validation and business rules. I find the distinct … | Continue reading
On the tension between encapsulation and testability. This article is part of a series called Epistemology of interaction testing. A previous article in the series elicited this question: "following your suggestion, aren’t we testing implementation details … | Continue reading
Mostly in C#, with a few lines of Haskell code. A recent article elicited more comments than usual, and I've been so unusually buried in work that only now do I have a little time to respond to some of them. In one comment Struan Judd offers a refactored version of my Co … | Continue reading
A pair of simple operations resurrected it. The other day I had an 'interesting' experience. I was about to create a small pull request, so I checked out a new branch in Git and switched to my editor in order to start coding when the battery on my laptop died. C … | Continue reading
How code files are organised is hardly related to sustainability of code bases. My recent article Folders versus namespaces prompted some reactions. A few kind people shared how they organise code bases, both on Twitter and in the comments. Most reactions, however, carry … | Continue reading
Yes, it involves JSON and regular expressions. Ever since I migrated the blog off dasBlog I've been writing the articles in raw HTML. The reason is mostly a historical artefact: Originally, I used Windows Live Writer, but Jekyll had no support for that, and since I'd bee … | Continue reading
What if you allow folder and namespace structure to diverge? I'm currently writing C# code with some first-year computer-science students. Since most things are new to them, they sometimes do things in a way that are 'not the way we usually do things'. As an example, tea … | Continue reading
A genuine case of doubt and bewilderment. Regular readers of this blog may be used to its confident and opinionated tone. I write that way, not because I'm always convinced that I'm right, but because prose with too many caveats and qualifications tends to bury the messa … | Continue reading
An example modifying a Haskell Gossiping Bus Drivers implementation. This is an article in an series of articles about the epistemology of interaction testing. In short, this collection of articles discusses how to test the composition of pure functions. While a pure fun … | Continue reading
I don't think so, and at least find the argument flawed. Increasingly I come across a quote that goes like this: Pull requests were invented for open source projects where you want to gatekeep changes from people you don't know and don't trust to change th … | Continue reading
A C# example with xUnit.net and FsCheck. This is the second comprehensive example that accompanies the article Epistemology of interaction testing. In that article, I argue that in a code base that leans toward functional programming (FP), property-based testing is a bette … | Continue reading
A futile exercise in code compaction. Recently I was doing the Anagrams kata in F# with Grzegorz Dziadkiewicz, and along the way realised that the implementation is essentially a one-liner. I thought it would be fun to redo the exercise in Haskell and see how compact cod … | Continue reading
A C# example with xUnit.net and CsCheck This is the first comprehensive example that accompanies the article Epistemology of interaction testing. In that article, I argue that in a code base that leans toward functional programming (FP), property-based testing is a better … | Continue reading
FAQ: What are the other pits of successes of functional programming? People who have seen my presentation Functional architecture: the pits of success occasionally write to ask: What are the other pits? The talk is about some of the design goals that we often struggle with in … | Continue reading
Can you trust your colleagues to write good code? Can you trust yourself? I've recently noticed a trend among some agile thought leaders. They talk about trust and gatekeeping. It goes something like this: Why put up barriers to prevent people from committ … | Continue reading
Recycling an old neologism of mine, I try to illustrate a point about the epistemology of testing function composition. This article continues the introduction of a series on the epistemology of interaction testing. In the first article, I attempted to explain how to tes … | Continue reading
TDD friction. Surely that's a bad thing(?) Paul Wilson recently wrote on Mastodon: Software development opinion (warnings as errors) Just seen this via Elixir Radar, https://curiosum.com/til/warnings-as-errors-elixir-mix-compile on on treating warnings as errors, and yeah … | Continue reading
With examples in C# and F#. This article is an instalment in an article series about monads. In other related series previous articles described Test Data Generator as a functor, as well as Test Data Generator as an applicative functor. As is the case with many (but not … | Continue reading
Is an inclusive workplace one that enables people to work at different hours? In the early noughties I worked for Microsoft Consulting Service in Denmark. In some sense it was quite the competitive working environment with an unhealthy focus on billable hours, customer sat … | Continue reading
How do we know that components interact correctly? Most software systems are composed as a graph of components. To be clear, I use the word component loosely to mean a collection of functionality - it may be an object, a module, a function, a data type, or perhaps something els … | Continue reading
Another most likely useless set of invariant functors that nonetheless exist. This article is part of a series of articles about invariant functors. An invariant functor is a functor that is neither covariant nor contravariant. See the series introduction for more details. It … | Continue reading
Why make things so complicated? Several readers reacted to my small article series on applicative assertions, pointing out that error-collecting assertions are already supported in more than one unit-testing framework. "In the Java world this seems similar to the result gain … | Continue reading
There are other agile methodologies than scrum. More than twenty years after the Agile Manifesto it looks as though there's only one kind of agile process left: Scrum. I recently held a workshop and as a side remark I mentioned that I don't consider scrum the best development … | Continue reading