March 12, 2012

Ditch the Grids and Use DockPanels

I have worked extensively with WinForms and WPF/Silverlight and noticed that docking/dock panels are not used that often.  At least this is the case where I work.  I find this surprising given their power and ease of use. Using XAML, why would a programmer choose a complex Grid/StackPanel setup over a DockPanel?  Or on the WinForms side, set the anchor properties for control rather than simplify things with the dock property? Read more

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 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

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

October 6, 2011

Creating a Crawl Control in WPF

A few weeks ago I was watching CNN when an interesting blurb scrolled by on the crawl at the bottom of the screen.  Normally, the crawl is not something I notice, but I thought to myself, "I wonder if I can implement one in WPF."  I had never done any animations before in WPF, and this seemed like a good way to start. So I gave it a shot. My initial instinct was to bring up Google and see if anyone else had done it. Read more

© Joe Buschmann 2020