February 14, 2012

Executing Actions Before and After Code Blocks with IDisposable

I ran into a scenario this week where a boolean field was being flipped temporarily to modify behavior elsewhere while a block of code was executing.  I have seen this pattern mainly in WinForms applications where data are being loaded into controls, but their events need to be suppressed during the load.  Afterward, the events should fire normally. Below is an example of this scenario.  It is a Windows form with a single combobox. 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

October 13, 2011

Creating Mocks with F# Object Expressions

When I read about F# object expressions, the first thought that popped into my head was to use them to create mocks for unit tests.  For those of you who are not familiar with object expressions, they are similar to anonymous classes in Java.  They are the object equivalent of lambda functions, and they allow you to create objects that implement an interface or base class without having to declare a new class. 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

July 16, 2011

My First Blog Post

I’ve always told myself that I needed to start blogging and get my thoughts out there. Well, after years of putting it off, I finally got started. I decided to write about what I love (besides my family of course): writing software using .NET. I’ll start out focusing on C# and F# language features. I’m proficient in C# but just starting out with F#. Functional programming is very different from what I’m used to; however, I’m liking it more and more. Read more

© Joe Buschmann 2020