August 6, 2015

String.Empty Versus ""

If you’ve been in the .NET world for any length of time, you’ll eventually come across someone who claims String.Empty performs better than "". I was always skeptical of this claim because this scenario seemed like something the compiler could optimize. And because the .NET runtime manages string literals in an intern pool, my guess was they would both point to the same value. That’s what I suspected anyway but didn’t have any proof. Read more

January 30, 2012

The Best Design Patterns

The first time I read the Gang of Four Design Patterns book, I was impressed, no blown away, by the brilliance of what I was reading. The Visitor pattern utilizing double-dispatch. Brilliant. Chain of Responsibility. Why didn’t I think of that? Adapter. Simple and powerful. Of course I was itching to start implementing these patterns. In practice though they seemed to be applicable only in rare situations. Adapter, Builder, Factory, Strategy, were the most useful. Read more

January 15, 2012

Text Parsing with F#

I've always had a fear of parsing text.  Strange since it's a basic programmer's task.  I've always found it to be tedious and boring, and the resulting code is a jumbled mess of indexes and string parsing methods.  I avoid it every chance I get. And there's regex.  The syntax is cryptic and difficult to remember.  It's another thing I should know well, but, again, I avoid it. Recently I decided to come to grips with this weakness and parse a text file containing information about TCP sockets in a TIME_WAIT status. Read more

August 15, 2011

The Dangers of Mutable Data

I recently came across a bug in some C# code that would never have been a problem if the data structures being used were immutable. The data consisted of a .NET dictionary with an integer key and a list as a value. The details below have been changed to protect the guilty. The offending method takes customer and product objects as parameters and retrieves a list of available pricing for the customer from a dictionary using the product ID as the key. Read more

July 28, 2011

Best Practices for Creating and Consuming Modal Dialogs in WinForms

This is an article I wrote a few years ago after seeing some bad coding practices around modal dialogs in WinForms. Bad habits like explicitly closing the dialog form and using custom OK/Cancel flags irked me, so I came up with some best practices. I hope you find them useful. Tip 1: Set the AcceptButton and CancelButton properties Windows Forms have two properties, AcceptButton and CancelButton, for determining what should be done when the user presses the Enter or Escape keys. Read more

July 18, 2011

F# Functions: Tuple Syntax

I’m relatively new to F# and functional programming and recently worked through an issue that had me perplexed. The issue was with creating functions with the “tuple syntax” versus the normal syntax of separating arguments by spaces. Consider the simple functions below that adds numeric arguments together. They are constructed in two ways. The first is by using a tuple to group the two arguments together. It looks very similar to the syntax from other languages such as C#. Read more

© Joe Buschmann 2020