Introducing EffectiveIoC

Last week I tweeted a few times about writing an IoC container in less than 60 lines of code.  I also blogged about how I thought the average IoC container was overly complex and didn’t promote DI-friendliness. Well, EffectiveIoC is the result of that short spike.  The core ended up being about 60 lines of code (supported type mappings—including open and closed generics—and app.config mappings).  I felt a minimum viable IoC container needed a little more than that, so I’ve also included programmatic configuration and support for instances (effectively singletons).  I’ve also thrown in the ability to map an action … Continue reading Introducing EffectiveIoC

Azure Table Storage and the Great Certificate Expiry of 2013

I won’t get into too much detail about what happened; but on 22-Feb-2013, roughly at 8pm the certificates used for *.table.core.windows.net expired.  The end result was that any application that used Azure Table Storage .NET API (or REST API and used the default certificate validation) began to fail connecting to Azure Table Storage.  More details can be found here.  At the time of this writing there hadn’t been anything published on any root cause analysis. The way that SSL/TLS certificates work is that they provide a means where a 3rd party can validate an organization (i.e. a server with a … Continue reading Azure Table Storage and the Great Certificate Expiry of 2013

Dispose Pattern and “Set large fields to null”

I was involved in a short side discussion about “should” fields be set to null in the Dispose method(s).  I’m not sure what the impetus of the question was; but, if you read through the dispose pattern MSDN documentation (in most versions I believe) there’s a comment // Set large fields to null. in the implementation of the virtual Dispose method within the if(!disposed) block and after the if(disposing) block.  But, that’s the only reference to setting fields to null during dispose.  There’s nothing else that I’ve been able to find in MSDN with regard to setting fields to null. … Continue reading Dispose Pattern and “Set large fields to null”

The Custom Configuration Section Code Smell

I was recently involved in a project that involved some design-time configuration.  That design-time configuration was based on custom config sections. I didn’t really pay too much attention to it at the time because I don’t write my own custom config sections.  As I worked on the project and do what I usually do by refactoring and evolving the system to use various patterns and principles, I came to realize why I don’t use my own custom config sections. That realization came as I began refactoring code for dependency inversion.  As I progressed getting the majority object creation code to … Continue reading The Custom Configuration Section Code Smell

Fluent Builders, Part 1

I’ve seen some conversations about fluent builders as of late, and I’d thought I’d post some information about fluent builders, the principles behind them, the problems they address, and how to implement them. Fluent Builder is a combination of the builder pattern and a fluent API. The builder pattern is similar to the factory pattern in that it’s intended to abstract the creation of other objects.  This is often meant to abstract the fact that many objects need to be created (ala the composite pattern).  It’s often intended to hide the fact that the creation of one object is dependant … Continue reading Fluent Builders, Part 1

Deep Dive on Closure Pitfalls

I’ve blogged about closures in C# and their pitfalls before.  I keep seeing problems with closures–more now that lambdas expressions and statements (“lambdas”) are becoming more widespread–even with experienced developers. So, I’d thought i’d post about some of the details surrounding where the C# compiler generates closures in the hopes that people will recognize more where they write code that creates a closure and its context. The C# language spec does not refer specifically to “closures”, with regard to capturing state for anonymous methods (including lambdas)–it refers to “outer variables” and “captured outer variables”.  The captured outer variables for a specific … Continue reading Deep Dive on Closure Pitfalls

Book Review: WCF 4.0 multi-tier services development with LINQ-to-Entities

WCF 4.0 Multi-Tier services development with LINQ-to-Entities is about about using LINQ with Entity Framework to create a data layer in a WCF web service.  The book approaches the content from the point of view of a junior developer–one that is not necessarily familiar with Visual Studio.  The book generally approaches the topic from a useful lowest-level to highest-level evolution–starting with how to create a WCF service from scratch and working up to creating a WCF service with the built-in Visual Studio templates.  The book follows the important contract-first design model for web services. I like the book’s approach to … Continue reading Book Review: WCF 4.0 multi-tier services development with LINQ-to-Entities

Using the dynamic Keyword in C# to Improve Object Orientation – A Follow-up

Based on some feedback, some clarification is warranted with regard to my previous post titled “Using the dynamic Keyword in C# to Improve Object Orientation”. As Jarek Kowalski correctly pointed out, the example code that I provided could have used the Visitor pattern instead to get the same result.  My impetus for using the dynamic keyword the way I did was slightly different from how I described my example—which was meant to be easier to read. I think it’s worthwhile describing the Visitor Pattern.  The Visitor pattern is a pattern used to separate the responsibility of an algorithm from the … Continue reading Using the dynamic Keyword in C# to Improve Object Orientation – A Follow-up

Using the dynamic Keyword in C# to Improve Object-Orientation

With polymorphism, object-oriented languages allow “…different data types to be handled using a uniform interface”.  Ad-hoc polymorphism is when you declare multiple methods of the same name but differ by the type of an argument.  For example: private static void Draw(Circle circle) { //… } private static void Draw(Square square) { //… } These are usually referred to as method overloads or method overloading.  Which Draw method that gets invoked would be decided upon at compile-time based on the type of the parameter passed to it. This is great, there are many situations where this is useful; but what about … Continue reading Using the dynamic Keyword in C# to Improve Object-Orientation

.NET 4.0, Evolving .NET Development

.NET 4.0 is the first release of .NET since 2.0 that evolves .NET for every programmer.  .NET 3.0 was largely LINQ and .NET 3.5 was largely new namespaces (like WCF, WWF, etc.) .NET 4.0 evolves the programming and design for any programmer.  It offers framework support for parallel processing (PFX will be released), Code Contracts (now DbC is a reality at the framework level, and opens the possibility of it being a reality at the language level post 2010), variance changes (co- and contra-variance on generics interfaces and delegates is now a reality). Parallel Processing Moore’s law has changed from … Continue reading .NET 4.0, Evolving .NET Development