C++ Refactoring: Default booleans and pointers

This is another recount of an experience I had refactoring some C++ code recently.  In some ways this is also a follow up of my previous post about why you shouldn’t use boolean parameters (especially default value ones). I recently refactored a large set of API’s in our code base to remove a common parameter. …

1

C++ Placement New: Tracking down a crash

See my previous two posts on an introduction to placement new if you are unfamiliar with the subject. http://blogs.msdn.com/jaredpar/archive/2007/10/16/c-new-operator-and-placement-new.aspx http://blogs.msdn.com/jaredpar/archive/2007/10/17/c-placement-new-and-allocators.aspx Recently I did a bit of work on the heap management story for our code base.  Mainly it was a change to unify the different ways we accessed our internal heap.  In the process I…

1

C++ Placement New and Allocators

This is a follow up for my previous post about operator new and placement new.  This post will discuss the role of adding a custom allocator and using it with new. It’s handy to use custom allocators in C++.  Certain operations can be done more efficiently on a different type of allocator than the rest…

2

C++ New Operator and Placement New

Originally I was going to write this article to detail a particular problem I had recently with placement new in C++.  A page or two of writing later I decided it would be best to start with an introduction to the “new” operator itself and the in/outs of overloading/replacing it.  The C++ new operator really…

5

Debugging PowerShell

Debugging PowerShell can be extremely frustrating because it often turns into a session of debugging your own thought process.  Often when I hit a PowerShell script issue I find myself feeling like everything is right and I’m just missing something basic.  IMHO, this is because I spend the majority of my day programming in compiled…

1

Select-StringRecurse

When you need to search for text in a file, select-string is your best friend.  It has most of the functionality of old unix grep.  In addition it does full regular expression support. The only downside is that it will only run on files in the current directory.  Unlike get-childitem, it has no recurse parameter. …

3

IEnumerable and IEnumerable(Of T) 2

Quick follow up to my earlier post.  Fixing this issue in C# is even easier because of the existence of iterators.  public static IEnumerable<object> Shim(System.Collections.IEnumerable enumerable) { foreach (var cur in enumerable) { yield return cur; } }

3

IEnumerable and IEnumerable(Of T)

IEnumerable(Of T) is a huge step up in the 2.0 framework from the original IEnumerable interface.  It provides a typed enumeration which eliminates lots of nasty casts.  The best part is that IEnumerable(Of T) is backwards compatible with IEnumerable (it inherits from it).  What’s frustrating is that IEnumerable is not forwards compatible with IEnumerable(Of Object). …

4

.Net Framework Source Code

If you haven’t heard the news yet, you can read the full article on ScottGu’s Blog.  In summary Microsoft has released the source code for the .Net Framework in such a way that you can step into the Framework while debugging.  IMHO this is great for users because it allows us to get a lot…

1

Casting to an Anonymous Type

This discussion is building upon a previous post on how to acquire an anonymous type … type.  The next question is, how can you cast an arbitrary object into an anonymous type?  At a glance this doesn’t seem possible as you cannot directly express the type of an anonymous type in code.  For instance the…

4