Handling a user transaction that spans multiple distributed systems

Jimmy Bogard’s excellent series on building a resilient distributed process apparently also comes as a talk.

In an hour he basically communicates the gist of Enterprise Integration Patterns and spells out what to watch out for and how to approach, learning about how to approach a distributed transaction (where MSDTC or the likes isn’t an option) doesn’t get any simpler than this.

Advertisement
Handling a user transaction that spans multiple distributed systems

String.CopyToUpper

So I just finished Writing High-Performance .NET Code, which is dry at times, but contains nuggets of wisdom.

One of them was something I should’ve understood, but really only now dawned on me.

Strings are immutable.

But like, really immutable.

This means any operation on them like calling ToUpper, results in the creation of a new string.

This behavior makes sense ofcourse, since they are immutable. You’re even reminded in the docs:

This method does not modify the value of the current instance. Instead, it returns a new string in which all characters in the current instance are converted to uppercase.

https://msdn.microsoft.com/en-us/library/ewdd6aed(v=vs.110).aspx

But intuitively while programming in your IDE, I will easily forget that I’m creating a new string. Unwittingly you could be increasing pressure on the garbage collector, deteriorating application performance, if you don’t pay attention in a hot application loop.

And I understand the string abstraction shouldn’t leak implementation details. But on the other hand, a name that is honest about what you are doing like .CopyToUpper, would save a lot of wasted CPU cycles in applications passed and to come 🙂

Theme music for this blog post

String.CopyToUpper