Category Archives: C

Prototyping with anonymous classes

In the last post, I presented a rather strange bit of code: public static class ExpressionExtensions { public static Expression<Func<T, TResult>> Expr<T, TResult>( this T item, Expression<Func<T, TResult>> expr) { return expr; } } It looks like a rather pointless … Continue reading 

| Leave a comment

Trivia Friday

Everybody loves a cliffhanger, right?  I found myself needing to write the following code the other day: public static class ExpressionExtensions { public static Expression<Func<T, TResult>> Expr<T, TResult>( this T item, Expression<Func<T, TResult>> expr) { return expr; } } Why … Continue reading 

| Leave a comment

Autoprojecting LINQ queries

Something I’ve been looking at adding to AutoMapper was the idea of doing automatic query projection in the Select query projection in LINQ statements.  One downside of AutoMapper is that projection from domain objects still forces the entire domain object … Continue reading 

| Leave a comment

Hiding Sensitive Information With A Base64 Encoded Dictionary And Binary Serialization

I’ve been back in C# land for the last few weeks writing a small Winforms application that runs from a USB thumb drive.   Need To Hide Some Data? We have a need to store some slightly-sensitive information that changes … Continue reading 

Also posted in .NET, C#, Data Access | 2 Comments

Good Refactoring / Patterns For Simple UI Logic?

I’ve got a chunk of C# that sits inside of a very simple form. The form downloads an update from a web page – one of two possible downloads, based on which one is available – and shows a message … Continue reading 

Also posted in .NET, C#, Pragmatism, Principles and Patterns, Refactoring | 7 Comments

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 

Also posted in .NET, Async, C#, WinForms | 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 

Also posted in .NET, Analysis and Design, Design Patterns, Principles and Patterns | 5 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 .NET, Agile, Behavior Driven Development, Continuous Integration, Resharper, Unit Testing | 5 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 

Also posted in .NET, AntiPatterns, C#, Principles and Patterns, Unit Testing | 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 

Also posted in .NET, C#, Refactoring | 28 Comments