FSZipper in C#

Another functional model of a file system, with code examples in C#. This article is part of a series about Zippers. In this one, I port the FSZipper data structure from the Learn You a Haskell for Great Good! article Zippers. A word of warning: I'm assuming that you're familiar … | Continue reading


@blog.ploeh.dk | 4 hours ago

Functor products

A tuple or class of functors is also a functor. An article for object-oriented developers. This article is part of a series of articles about functor relationships. In this one you'll learn about a universal composition of functors. In short, if you have a product type of functor … | Continue reading


@blog.ploeh.dk | 7 days ago

A Binary Tree Zipper in C#

A port of another Haskell example, still just because. This article is part of a series about Zippers. In this one, I port the Zipper data structure from the Learn You a Haskell for Great Good! article also called Zippers. A word of warning: I'm assuming that you're familiar with … | Continue reading


@blog.ploeh.dk | 14 days ago

Keeping cross-cutting concerns out of application code

Don't inject third-party dependencies. Use Decorators. I recently came across a Stack Overflow question that reminded me of a topic I've been meaning to write about for a long time: Cross-cutting concerns. When it comes to the usual suspects, logging, fault tolerance, caching, th … | Continue reading


@blog.ploeh.dk | 21 days ago

A List Zipper in C#

A port of a Haskell example, just because. This article is part of a series about Zippers. In this one, I port the ListZipper data structure from the Learn You a Haskell for Great Good! article also called Zippers. A word of warning: I'm assuming that you're familiar with the con … | Continue reading


@blog.ploeh.dk | 27 days ago

Zippers

Some functional programming examples ported to C#, just because. Many algorithms rely on data structures that enable the implementation to move in more than one way. A simple example is a doubly-linked list, where an algorithm can move both forward and backward from a given eleme … | Continue reading


@blog.ploeh.dk | 1 month ago

Using only a Domain Model to persist restaurant table configurations

A data architecture example in C# and ASP.NET. This is part of a small article series on data architectures. In this, the third instalment, you'll see an alternative way of modelling data in a server-based application. One that doesn't rely on statically typed classes to model da … | Continue reading


@blog.ploeh.dk | 1 month ago

Using a Shared Data Model to persist restaurant table configurations

A data architecture example in C# and ASP.NET. This is part of a small article series on data architectures. In this, the second instalment, you'll see a common attempt at addressing the mapping issue that I mentioned in the previous article. As the introductory article explains, … | Continue reading


@blog.ploeh.dk | 1 month ago

Using Ports and Adapters to persist restaurant table configurations

A data architecture example in C# and ASP.NET. This is part of a small article series on data architectures. In the first instalment, you'll see the outline of a Ports and Adapters implementation. As the introductory article explains, the example code shows how to create a new re … | Continue reading


@blog.ploeh.dk | 1 month ago

Three data architectures for the server

A comparison, for educational purposes. Use the right tool for the job. How often have you encountered that phrase when discussing software architecture? There's nothing wrong with the sentiment per se, but it's almost devoid of meaning. It doesn't pass the 'not test'. Try to neg … | Continue reading


@blog.ploeh.dk | 1 month ago

The end of trust?

Software development in a globalized, hostile world. Imagine that you're perusing the thriller section in an airport book store and come across a book with the following back cover blurb: Programmers are dying. Holly-Ann Kerr works as a data scientist for an NGO that fights workp … | Continue reading


@blog.ploeh.dk | 2 months ago

Should interfaces be asynchronous?

Async and await are notorious for being contagious. Must all interfaces be Task-based, just in case? I recently came across this question on Mastodon: "To async or not to async? "How would you define a library interface for a service that probably will be implemented with an in m … | Continue reading


@blog.ploeh.dk | 2 months ago

An immutable priority collection

With examples in C# and F#. This article is part of a series about encapsulation and immutability. After two attempts at an object-oriented, mutable implementation, I now turn toward immutability. As already suggested in the introductory article, immutability makes it easier to m … | Continue reading


@blog.ploeh.dk | 2 months ago

A mutable priority collection

An encapsulated, albeit overly complicated, implementation. This is the second in a series of articles about encapsulation and immutability. In the next article, you'll see how immutability makes encapsulation easier, but in order to appreciate that, you should see the alternativ … | Continue reading


@blog.ploeh.dk | 3 months ago

A failed attempt at priority collection with inheritance

An instructive dead end. This article is part of a short series on encapsulation and immutability. As the introductory article claims, object mutation makes it difficult to maintain invariants. In order to demonstrate the problem, I deliberately set out to do it wrong, and report … | Continue reading


@blog.ploeh.dk | 3 months ago

Simpler encapsulation with immutability

A worked example. I've noticed that many software organizations struggle with encapsulation with 'bigger' problems. It may be understandable and easily applicable to define a NaturalNumber type or ensure that a minimum value is less than a maximum value, and so on. How do you, ho … | Continue reading


@blog.ploeh.dk | 3 months ago

You'll regret using natural keys

Beating another dead horse. Although I live in Copenhagen and mostly walk or ride my bicycle in order to get around town, I do own an old car for getting around the rest of the country. In Denmark, cars go through mandatory official inspection every other year, and I've been thro … | Continue reading


@blog.ploeh.dk | 3 months ago

Continuous delivery without a CI server

An illustrative example. More than a decade ago, I worked on a small project. It was a small single-page application (SPA) with a REST API backend, deployed to Azure. As far as I recall, the REST API used blob storage, so all in all it wasn't a complex system. We were two develop … | Continue reading


@blog.ploeh.dk | 3 months ago

Fundamentals

How to stay current with technology progress. A long time ago, I landed my dream job. My new employer was a consulting company, and my role was to be the resident Azure expert. Cloud computing was still in its infancy, and there was a good chance that I might be able to establish … | Continue reading


@blog.ploeh.dk | 4 months ago

Gratification

Some thoughts on developer experience. Years ago, I was introduced to a concept called developer ergonomics. Despite the name, it's not about good chairs, standing desks, or multiple monitors. Rather, the concept was related to how easy it'd be for a developer to achieve a certai … | Continue reading


@blog.ploeh.dk | 4 months ago

Conservative codomain conjecture

An API design heuristic. For a while now, I've been wondering whether, in the language of Postel's law, one should favour being liberal in what one accepts over being conservative in what one sends. Yes, according to the design principle, a protocol or API should do both, but som … | Continue reading


@blog.ploeh.dk | 4 months ago

Service compatibility is determined based on policy

A reading of the fourth Don Box tenet, with some commentary. This article is part of a series titled The four tenets of SOA revisited. In each of these articles, I'll pull one of Don Box's four tenets of service-oriented architecture (SOA) out of the original MSDN Magazine articl … | Continue reading


@blog.ploeh.dk | 4 months ago

Fitting a polynomial to a set of points

The story of a fiasco. This is the second in a small series of articles titled Trying to fit the hype cycle. In the introduction, I've described the exercise I had in mind: Determining a formula, or at least a piecewise function, for the Gartner hype cycle. This, to be clear, is … | Continue reading


@blog.ploeh.dk | 5 months ago

Services share schema and contract, not class

A reading of the third Don Box tenet, with some commentary. This article is part of a series titled The four tenets of SOA revisited. In each of these articles, I'll pull one of Don Box's four tenets of service-oriented architecture (SOA) out of the original MSDN Magazine article … | Continue reading


@blog.ploeh.dk | 5 months ago

Extracting curve coordinates from a bitmap

Another example of using Haskell as an ad-hoc scripting language. This article is part of a short series titled Trying to fit the hype cycle. In the first article, I outlined what it is that I'm trying to do. In this article, I'll describe how I extract a set of x and y coordinat … | Continue reading


@blog.ploeh.dk | 5 months ago

Trying to fit the hype cycle

An amateur tries his hand at linear modelling. About a year ago, I was contemplating a conference talk I was going to give. Although I later abandoned the idea for other reasons, for a few days I was thinking about using the Gartner hype cycle for an animation. What I had in mind … | Continue reading


@blog.ploeh.dk | 5 months ago

Services are autonomous

A reading of the second Don Box tenet, with some commentary. This article is part of a series titled The four tenets of SOA revisited. In each of these articles, I'll pull one of Don Box's four tenets of service-oriented architecture (SOA) out of the original MSDN Magazine articl … | Continue reading


@blog.ploeh.dk | 6 months ago

Extracting data from a small CSV file with Python

My inept adventures with a dynamically typed language. This article is the third in a small series about ad-hoc programming in two languages. In the previous article you saw how I originally solved a small data extraction and analysis problem with Haskell, even though it was stro … | Continue reading


@blog.ploeh.dk | 6 months ago

Boundaries are explicit

A reading of the first Don Box tenet, with some commentary. This article is part of a series titled The four tenets of SOA revisited. In each of these articles, I'll pull one of Don Box's four tenets of service-oriented architecture (SOA) out of the original MSDN Magazin … | Continue reading


@blog.ploeh.dk | 6 months ago

The four tenets of SOA revisited

Twenty years after. In the January 2004 issue of MSDN Magazine you can find an article by Don Box titled A Guide to Developing and Running Connected Systems with Indigo. Buried within the (now dated) discussion of the technology code-named Indigo (later Windows Communica … | Continue reading


@blog.ploeh.dk | 6 months ago

Testing exceptions

Some thoughts on testing past the happy path. Test-driven development is a great development technique that enables you to get rapid feedback on design and implementation ideas. It enables you to rapidly move towards a working solution. The emphasis on the happy … | Continue reading


@blog.ploeh.dk | 7 months ago

Extracting data from a small CSV file with Haskell

Statically typed languages are also good for ad-hoc scripting. This article is part of a short series of articles that compares ad-hoc scripting in Haskell with solving the same problem in Python. The introductory article describes the problem to be solved, so here I'll … | Continue reading


@blog.ploeh.dk | 7 months ago

Range as a functor

With examples in C#, F#, and Haskell. This article is an instalment in a short series of articles on the Range kata. In the previous three articles you've seen the Range kata implemented in Haskell, in F#, and in C#. The reason I engaged with this kata was that … | Continue reading


@blog.ploeh.dk | 7 months ago

Statically and dynamically typed scripts

Extracting and analysing data in Haskell and Python. I was recently following a course in mathematical analysis and probability for computer scientists. One assignment asked to analyze a small CSV file with data collected in a student survey. The course contained a mix o … | Continue reading


@blog.ploeh.dk | 7 months ago

Error categories and category errors

How I currently think about errors in programming. A reader recently asked a question that caused me to reflect on the way I think about errors in software. While my approach to error handling has remained largely the same for years, I don't think I've described it in an … | Continue reading


@blog.ploeh.dk | 7 months ago

A Range kata implementation in C#

A port of the corresponding F# code. This article is an instalment in a short series of articles on the Range kata. In the previous article I made a pass at the kata in F#, using property-based testing with Hedgehog to generate test data. In the conclusion I mus … | Continue reading


@blog.ploeh.dk | 8 months ago

A Range kata implementation in F#

This time with some property-based testing. This article is an instalment in a short series of articles on the Range kata. In the previous article I described my first attempt at the kata, and also complained that I had to think of test cases myself. When I find it tedio … | Continue reading


@blog.ploeh.dk | 8 months ago

A Range kata implementation in Haskell

A first crack at the exercise. This article is an instalment in a short series of articles on the Range kata. Here I describe my first attempt at the exercise. As I usually advise people on doing katas, the first time you try your hand at a kata, use the language with wh … | Continue reading


@blog.ploeh.dk | 8 months ago

Variations of the Range kata

In the languages I usually employ. The Range kata is succinct, bordering on the spartan in both description and requirements. To be honest, it's hardly the most inspiring kata available, and yet it may help showcase a few interesting points about software design in gener … | Continue reading


@blog.ploeh.dk | 8 months ago

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 | 9 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 | 9 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 | 9 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 | 9 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 | 10 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 | 10 months 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 | 10 months 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 | 10 months 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 | 10 months ago