Serializing restaurant tables in C#

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


@blog.ploeh.dk | 11 months ago

Serializing restaurant tables in F#

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


@blog.ploeh.dk | 11 months ago

Serializing restaurant tables in Haskell

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


@blog.ploeh.dk | 11 months ago

Serialization with and without Reflection

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


@blog.ploeh.dk | 11 months ago

Synchronizing concurrent teams

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


@blog.ploeh.dk | 12 months ago

Trimming a Fake Object

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


@blog.ploeh.dk | 1 year ago

CC golf

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


@blog.ploeh.dk | 1 year ago

Fakes are Test Doubles with contracts

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


@blog.ploeh.dk | 1 year ago

A C# port of validation with partial round trip

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


@blog.ploeh.dk | 1 year ago

Domain Model first

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


@blog.ploeh.dk | 1 year ago

At the boundaries, static types are illusory

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


@blog.ploeh.dk | 1 year ago

What's a sandwich?

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


@blog.ploeh.dk | 1 year ago

Dependency Whac-A-Mole

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


@blog.ploeh.dk | 1 year ago

The case of the mysterious comparison

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


@blog.ploeh.dk | 1 year ago

Do ORMs reduce the need for mapping?

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


@blog.ploeh.dk | 1 year ago

Decomposing CTFiYH's sample code base

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


@blog.ploeh.dk | 1 year ago

A first crack at the Args kata

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


@blog.ploeh.dk | 1 year ago

Compile-time type-checked truth tables

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


@blog.ploeh.dk | 1 year ago

Replacing Mock and Stub with a Fake

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


@blog.ploeh.dk | 1 year ago

NonEmpty catamorphism

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


@blog.ploeh.dk | 1 year ago

Test-driving the pyramid's top

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


@blog.ploeh.dk | 1 year ago

Is software getting worse?

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


@blog.ploeh.dk | 1 year ago

Works on most machines

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


@blog.ploeh.dk | 1 year ago

AI for doc comments

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


@blog.ploeh.dk | 1 year ago

Validating or verifying emails

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


@blog.ploeh.dk | 1 year ago

Validation and business rules

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


@blog.ploeh.dk | 1 year ago

When is an implementation detail an implementation detail?

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


@blog.ploeh.dk | 1 year ago

Collatz sequences by function composition

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


@blog.ploeh.dk | 1 year ago

The Git repository that vanished

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


@blog.ploeh.dk | 1 year ago

Favour flat code file folders

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


@blog.ploeh.dk | 1 year ago

Visual Studio Code snippet to make URLs relative

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


@blog.ploeh.dk | 1 year ago

Folders versus namespaces

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


@blog.ploeh.dk | 1 year ago

Is cyclomatic complexity really related to branch coverage?

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


@blog.ploeh.dk | 1 year ago

Refactoring pure function composition without breaking existing tests

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


@blog.ploeh.dk | 1 year ago

Are pull requests bad because they originate from open-source development?

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


@blog.ploeh.dk | 1 year ago

A restaurant example of refactoring from example-based to property-based testing

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


@blog.ploeh.dk | 1 year ago

Anagrams kata as a one-liner

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


@blog.ploeh.dk | 1 year ago

An abstract example of refactoring from interaction-based to property-based testing

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


@blog.ploeh.dk | 1 year ago

More functional pits of success

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


@blog.ploeh.dk | 1 year ago

On trust in software development

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


@blog.ploeh.dk | 1 year ago

Confidence from Facade Tests

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


@blog.ploeh.dk | 1 year ago

Warnings-as-errors friction

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


@blog.ploeh.dk | 1 year ago

Test Data Generator monad

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


@blog.ploeh.dk | 1 year ago

A thought on workplace flexibility and asynchrony

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


@blog.ploeh.dk | 1 year ago

Epistemology of interaction testing

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


@blog.ploeh.dk | 1 year ago

Contravariant functors as invariant functors

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


@blog.ploeh.dk | 1 year ago

Built-in alternatives to applicative assertions

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


@blog.ploeh.dk | 1 year ago

Agilean

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


@blog.ploeh.dk | 1 year ago