Category Archives: C

Asynchronous Control Updates In C#/.NET/WinForms

Every .NET WinForms project I’ve written, since .NET 2.0, has included some form of this code: public static class ControlExtensions {   public static void Do<TControl>(this TControl control, Action<TControl> action)     where TControl: Control   {     if (control.InvokeRequired)       control.Invoke(action, … Continue reading 

| 4 Comments

Hello World in C, Dev Setup

As mentioned, I’m learning C, and I’ve achieved hello-world, plus recursive calculations of factorials and some data structures. Whee. :) For those playing along at home, I’ll describe my dev setup. But first, an unexpected discovery: Counter to my intuition, … Continue reading 

| 4 Comments

Dipping into C

I decided on Monday that I should learn C. Cultivate a nodding acquaintance, at any rate. Louis is always prodding me to become a better craftsman, to become more proficient with my tools. So I figured I should understand my … Continue reading 

Also posted in books | 8 Comments

A Response To “What Is An Interface” By John Sonmez

this started out as a very lengthy reply to john sonmez’ post on What Is An Interface. There’s enough that I want to say that I think it warrants me posting on my blog instead of blogging in his comment … Continue reading 

| 7 Comments

A Less Ugly Switch Statement For C#

I know switch statements are considered “evil” because they are very procedural code, they violate the Open-Closed Principle, etc etc. But every now and then I don’t see a need to do anything more than a switch statement because the … Continue reading 

| Leave a comment

A DSL For Handling Zero, One, Many

All this talk about refactoring to clean up code and monads to create pipelines has put me on a code composition kick… I wrote this code today: 1: private AddAssetResult HandleAssetFamily(SortContainer container, SystemAsset systemAsset) 2: { 3: AddAssetResult result = … Continue reading 

| Leave a comment

Monads in C#: Which Part Is The Monad?

In my previous post on refactoring some code, several people responded in the comments and via twitter that I should look at the Maybe<T> monad as an option. Now, I have to be honest… the potty-humor-teenager in me wants to … Continue reading 

| Leave a comment

A Refactoring: Explicit Modeling And Reducing Duplication

A coworker showed me a method that had a series of guard clauses at the top and a series of sequential steps that had to be processed after that. All of the guard clauses and sequential steps were executed the … Continue reading 

| Leave a comment

Domain Models, Dependencies And Fighting Anemia

For a long time now, I’ve been in the camp that says you shouldn’t have domain entities take dependencies… but at this point I’m having a hard time remembering why. I’m sure I could dig up my old notes and … Continue reading 

| 21 Comments

A question for Rubyists

I was checking out this post from Derick Bailey today, and something struck me rather odd.  Not the “DI only enables testability” argument, but the ruby code: class Foo    def bar     baz = Baz.new     baz.do_something   end end I’ve been very … Continue reading 

| Leave a comment