
Ploeh Blog - Mark Seemann
266 FOLLOWERS
Mark Seemann helps programmers make source code easier to maintain. Experienced programmer and international conference speaker, particularly interested in functional programming and object-oriented design with Haskell, F# and C#. Occasionally writes and speaks about various development topics.
Ploeh Blog - Mark Seemann
6d ago
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 the (subliminal?) subtext that organising code in file folders is how things are done.
I'd like to challenge that notion.
As is usually my habit, I mostly do this to make you think. I don't insist that I'm universally right in all contexts, and that everyone else are wrong. I only write to suggest that alternatives exist.
The ..read more
Ploeh Blog - Mark Seemann
1w ago
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 been doing web development for more than a decade already, raw HTML seemed like a reliable and durable alternative. I increasingly find that relying on skill and knowledge is a far more durable strategy than relying on technology.
For a decade I used Sublime Text to write articles, but over the years, I found it degrading in qual ..read more
Ploeh Blog - Mark Seemann
2w ago
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, teachers have instructed them to use namespaces, but apparently no-one have told them that the file folder structure has to mirror the namespace structure.
The compiler doesn't care, but as long as I've been programming in C#, it's been idiomatic to do it that way. There's even a static code analysis rule about it.
The first coup ..read more
Ploeh Blog - Mark Seemann
3w ago
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 message in verbose and circumlocutory ambiguity.
This time, however, I write to solicit feedback, and because I'm surprised to the edge of bemusement by a recent experience.
Collatz sequence #
Consider the following code:
public static class Collatz
{
public static IReadOnlyCollection<int> Sequence(int n)
{
i ..read more
Ploeh Blog - Mark Seemann
1M ago
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 function is intrinsically testable, how do you test the composition of pure functions? As the introductory article outlines, I consider it mostly a matter of establishing confidence. With enough test coverage you can be confident that the composition produces the desired outputs.
Keep in mind that if you compose pure functions in ..read more
Ploeh Blog - Mark Seemann
1M ago
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 the code safely.
If you're wondering where that 'quote' comes from, then read on. I'm not trying to stand up a straw man, but I had to do a bit of digging in order to find the source of what almost seems like a meme.
Quote investigation #
The quote is usually attributed to Dave Farley, who is a software luminary that I respect tremendously ..read more
Ploeh Blog - Mark Seemann
1M ago
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 better fit than interaction-based testing. In this example, I will show how to refactor realistic state-based tests into (state-based) property-based tests.
The previous article showed a minimal and self-contained example that had the advantage of being simple, but the disadvantage of being perhaps too abstract and unrelatable. I ..read more
Ploeh Blog - Mark Seemann
2M ago
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 code I could get away with.
In short, in the exercise, you're given a list of words, and you need to find all the anagrams in the list. For example, given the list bar, foo, bra, the result should be bar, bra, and foo shouldn't be part of the output, since it's not an anagram of any other word in the list.
A pipeline of transform ..read more
Ploeh Blog - Mark Seemann
2M ago
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 fit than interaction-based testing. In this example, I will show how to refactor simple interaction-based tests into a property-based tests.
This small article series was prompted by an email from Sergei Rogovtsev, who was kind enough to furnish example code. I'll use his code as a starting point for this example, so I've fo ..read more
Ploeh Blog - Mark Seemann
2M ago
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 object-oriented programming, but which tend to happen automatically in functional programming (FP). In the presentation I cover three pits of success, but I also mention that there are more. In a one-hour conference presentation, I simply didn't have time to discuss more than three.
It's a natural question, then, to ask ..read more