Programming
Reverse a dictionary
1Have you ever wished your dictionary of <K,V> was in fact of <V,K>? I might be the last person to figure this out, but with LINQ (and a couple lambdas) you can do this with one magical line of code:
var newDict = oldDict.ToDictionary(l => l.Value, l => l.Key); |
Neat, eh?
Become a Jedi with Resharper
0If you work in C# or VB.net on a regular basis, you really owe it to yourself to try out Resharper. This tool saves me countless hours.
James Kovacs put together some fantastic screencasts on “Becoming a Jedi” that show it in action, if you are curious.
He hasn’t covered the features that make it a boon for test driven development yet, but there’s another great screencast that shows that off, and this post provides some additional details on “coding in reverse” with Resharper.
Order of operations
2Sometimes I can be such a buffoon. When programming with threads, one must be sure to lock and unlock in the correct order. Also, one must be sure not to do things explicitly marked as no-nos while in a “critical section.”
I just lost two hours to this, so I felt the need to whine.
On programming for fun.
2I wonder if it is the nature of the beast that when someone does something for a living day in and day out, it stops being fun. I’m starting to worry that may be the case with me.
Why am I bringing this up? One reason is due to watching my friend Rab [having fun with Python][hobby]. He’s having fun. He’s doing it for fun, and thus he’s having fun. Doesn’t that sound like fun? It does to me. Yet he’s doing the same thing I do as a job, and I don’t have fun. Maybe it is because he’s writing a game?
Reading his adventures, and talking with him about python programming is fun. It makes me want to start programming for fun too. As it doesn’t make sense to me for the idea of programming to be fun but the programming itself not to be, I suppose I’m just looking at the the wrong way. Maybe all I need to do is adjust my point of view, and I’ll start having fun again. I say again because I did enjoy programming once. I know it is possible for me to do so.
Thus starts the experiment. I’m not sure yet how I’m going to approach this. Perhaps the best method is to just adjust my thinking — find the “game” in whatever I’m doing, cling to it, and use that shape my overall view.
[hobby]: http://robertbeverly.com/2007/02/17/hobby-programming/