Should interfaces be asynchronous?
Ploeh Blog - Mark Seemann
by
2w ago
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 memory procedure - let's say returning a mapped value to a key you registered programmatically - and a user of your API might want to implement a decorator that needs a 'long running task' - for example you want to log a msg into your db or load additional mapping from a file? "Would you define the interface to return ..read more
Visit website
An immutable priority collection
Ploeh Blog - Mark Seemann
by
3w ago
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 maintain invariants. In the introductory article, I described the example problem in more details, but in short, the exercise is to develop a class that holds a collection of prioritized items, with the invariant that the priorities must always sum to 100. It should be impossible to leave the object in a state where th ..read more
Visit website
A mutable priority collection
Ploeh Blog - Mark Seemann
by
1M ago
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 alternative. This article, then, shows a working, albeit overly complicated, implementation that does maintain its invariants. In the introductory article, I described the example problem in more details, but in short, the exercise is to develop a class that holds a collection of prioritized items, with the invariant that the p ..read more
Visit website
A failed attempt at priority collection with inheritance
Ploeh Blog - Mark Seemann
by
1M ago
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 on the result. In subsequent articles in this series I will then show one way you can maintain the invariants in the face of mutation, as well as how much easier everything becomes if you choose an immutable design. For now, however, I'll pretend to be naive and see how far I can get with that. In the first article ..read more
Visit website
Simpler encapsulation with immutability
Ploeh Blog - Mark Seemann
by
1M ago
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, however, guarantee invariants once the scope of the problem becomes bigger and more complex? In this series of articles, I'll attempt to illustrate how and why this worthy design goal seems elusive, and what you can do to achieve it. Contracts # As usual, when I discuss encapsulation, I first need to establish what I me ..read more
Visit website
You'll regret using natural keys
Ploeh Blog - Mark Seemann
by
1M ago
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 through a few of these in my life. A few years ago, the mechanic doing the inspection informed me that my car's chassis number was incorrect. This did make me a bit nervous, because I'd bought the car used, and I was suddenly concerned that things weren't really as I thought. Had I unwittingly bought a stolen car? But the ..read more
Visit website
Continuous delivery without a CI server
Ploeh Blog - Mark Seemann
by
2M ago
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 developers, and although we wanted to do continuous delivery (CD), we didn't have much development infrastructure. This was a little startup, and back then, there weren't a lot of free build services available. We were using GitHub, but it was before it had any free services to compile your code and run tests. Given those co ..read more
Visit website
Fundamentals
Ploeh Blog - Mark Seemann
by
2M ago
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 myself as a leading regional authority on the topic. As part of the role, I was supposed to write articles and give presentations showing how to solve various problems with Azure. I dug in with fervour, writing sample code bases and even an MSDN Magazine article. To my surprise, after half a year I realized that I wa ..read more
Visit website
Gratification
Ploeh Blog - Mark Seemann
by
2M ago
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 certain outcome. How easy is it to set up a new code base in a particular language? How much work is required to save a row in a database? How hard is it to read rows from a database and display the data on a web page? And so on. These days, we tend to discuss developer experience rather than ergonomics, and that's probably ..read more
Visit website
Conservative codomain conjecture
Ploeh Blog - Mark Seemann
by
2M ago
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 sometimes, you can't do that. Instead, you'll have to choose. I've recently reached the tentative conclusion that it may be a good idea favouring being conservative in what one sends. Good API design explicitly considers contracts. What are the preconditions for invoking an operation? What are the postconditions? Are the ..read more
Visit website

Follow Ploeh Blog - Mark Seemann on FeedSpot

Continue with Google
Continue with Apple
OR