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

Dynamic Features in C#

.NET is the evolution of COM.  .NET was rumoured to be originally called COM+ 2.5. .NET has evolved well beyond COM and while it fulfils many of the goals that COM originally tried to fulfil, .NET removes many of the COM trappings that developers have to deal with. C# is a .NET language with C++ heritage.  C++, unlike VB is not a dynamic language.  C# was only dynamic in that it provided COM interop abilities.  You can program to any COM API you like, as long as you know what you’re talking to.  This is generally not a problem for … Continue reading Dynamic Features in C#

My Wishlist for C# 4

[Edit: fixed the not-ready-for-publication problems]  There seems to be more than few people blogging about what they hope C# 4 will do for them.  I haven’t seen one that really synchronizes with my thoughts, so I’d thought I’d post my own list. Variance A good story with regard to variance with generics is vital for upcoming versions of C# 4.  You could argue that this should have been done in 3, but, unfortunately, that wasn’t the focus.  I think this really needs to be done for 4; and if Eric Lippert’s blog is any indication, that may come true. Design … Continue reading My Wishlist for C# 4