Not so long ago I stumbled upon a minor feature that I haven’t seen before and I gotta say that I really like it. It might be simple but it can save some trouble.

Todays little tip is about the class named DebuggerDisplay. Have you ever been annoyed by the fact that Visual Studio only shows you the classtype when you hover over one of your own classes (or look at it in watches) while allot of other classes show you more info. For a long while I’ve been thinking that the trick was to override ToString on all my objects, but that doesn’t really come to me as a good idea for just showing data while debugging. There is allot of cases where you want different stuff to be quickly inspected in the debugger than you want to send out in ToString.

If we quickly look at the two photos (click to see a full size) bellow we’ll see that there is a VERY small difference in the code but as a matter a fact it makes a huge difference when debugging (or well that’s my opinion).

Old code:

New code:

It’s a neat little trick, it takes no time to write but it’ll help you allot in the future of your debugging :)

Tags: ,

Comments Comments Off

For good times sake of people being curious about my install of WordPress…

Currently I’m running a very low modified WordPress install to keep it as simple as possible to maintain. I can’t be bothered with major update scenarios and so on, it doesn’t really interest me to do stuff like that :)

Of course my basic install have the Akismet spam filter enabled, cause I can’t be bothered to go and check comments every second of the day. I really love this plugin cause I’ve never had any false-positives in it, so kudos to the guys behind it.

If you look at the upper left of my site I have Quotes Collection by Srini G running, I’m so into good/funny/odd quotes every now and then (people on my MSN list would know for sure). It runs as a simple small widget on your site, the quotes are maintained in the tools section of the website. I would say that you can enter and enable a new quote within 1 minute if you are a slowpoke :)

All my images (when I remember to put the proper link on the image) are handled by Lightbox 2 by Rupert Morris, a nice little plugin that shows all images in a pop-up lightbox instead of redirecting the user to another page just to see a bigger image.

Now for one of the more tricky plugins I have my source code viewer, it is SyntaxHighlighter Evolved by Viper007Bond. I’m still annoyed by some of the “features” in it, for example when I copy my source code from Visual Studio it never seems to get the tabbing right. So far I’m editing all the indents by hand in the post editing, I find it really annoying when I can see that it catches the indent on the first set of braces. Besides that there is a really annoying bug when you go back and edit a post…it html-encodes some of the special characters, which leads you to go back and type those characters again :(

For my never ending list of plugins I use WordTwit by Dale Mugford & Duane Storey (BraveNewCode) for automatically posting a reference to Twitter. I started using Twitter by the start of April (2010) and I gotta say I’m starting to like it allot better than facebook for my everyday stuff. Sometimes I even catch myself thinking “when did you last status update facebook” :) The same guys have actually made another cool plugin that I’m using … WPTouch iPhone Theme basically a plugin that does some fancy wrapping when it catches the iPhone user-agent.

Tags:

Comments Comments Off

I went on a minor book shopping spree last week.
I tried to find a really good book for developers that wasn’t only about code (besides that it was VERY recommended reading on StackOverflow). So after some shuffling around Amazon.co.uk I decided to buy “Code Complete 2nd Edition” by Steven McConnell. So far I haven’t had much time to read anything in it, but I’m really looking forward to reading all the hints, guides, best practices etc. in it.

If you think you need something to develop your developer mind, go ahead give it a try. Get it at Amazon.co.uk!

Besides a not-so-technical book I also needed a good way to update my C# knowledge to 3.0/3.5 and even more important 4.0. There is so much stuff that has been introduced with .NET 4.0 so I needed a good source for it.

What better book to get that “C# in Depth, 2nd Edition” by the one and only Jon Skeet. For those of you not wanting to spend your valuable time on StackOverflow (first of all you should!), you should just live with the fact that he is the Chuck Norris of C#. The downside of wanting this book is that it isn’t available in printed form yet, but Manning decided to run a very cool offer where you get a personal eBook copy of the book while you are waiting on the printed version. I bought the book directly at Manning so I’m expecting to get raped by the danish government for importing a book since it’ll be shipped from USA :)

On a different topic I also bought “Into the Wild” by Jon Krakauer and “Consilience” by Edward O. Wilson. I pretty much bought Into the Wild because I saw the movie and liked the mindset of Chris McCandless, and wondered how much stuff the movie left out. I’ll probably read it sometime during this summer. Concerning Consilience I have no clue what to expect, I think I heard about it on a podcast (think it was with Scott Hanselman) and checked the back of it and well it intrigued me so now I own a copy.

Tags: , ,

Comments Comments Off

How often do you work with paths?

Quite allot of people don’t really take their time to look at the “minor” stuff in the .NET Framework, and one of the classes I see skipped is something as plain and simple as Path. I don’t think anyone at the office used it before I started back in October (dunno, and don’t really care cause there is nothing won by looking back and wondering).

How would a developer usually handle a path?

The old way:

namespace Sleddog.CodeTips.CodeTip002
{
 class Program
 {
  static void Main( string[] args )
  {
   string filePath = @"F:\Code\CodeTips\CodeTip002\CodeTip002\Program.cs";

   string oldFileName = filePath.Substring( filePath.LastIndexOf( "\\" ) + 1 );
   string oldPath = filePath.Substring( 0, filePath.LastIndexOf( "\\" ) );
   string oldFullPath = oldPath + "\\" + oldFileName;
  }
 }
}

Now when we look at the old fashion way, there isn’t much about it but…be honest here, how often haven’t you forgotten the +1 when you are doing LastIndexOf( … ) or when was the last time you forgot the \ between the path and the filename. I see allot of people running their code and afterwards going back and correcting this minor mishap, it doesn’t kill you at all but it could be really cool not having the trial/error way of doing stuff.

The new way:

namespace Sleddog.CodeTips.CodeTip002
{
 class Program
 {
  static void Main( string[] args )
  {
   string filePath = @"F:\Code\CodeTips\CodeTip002\CodeTip002\Program.cs";

   string newFileName = Path.GetFileName( filePath );
   string newPath = Path.GetDirectoryName( filePath );
   string newFullPath = Path.Combine( newPath, newFileName );
  }
 }
}

The new way looks way less techy, but do I care? No! not at all, I didn’t start writing code because it should look technical. I started writing code cause I had to choose an education so I followed the rest of the nerds from my hometown…eeeh back on the track again. Code is not meant to be hard to read, if you think so then you are failing BIG TIME! The easier the code is to read the less time you need to spend at the office doing boring stuff, the more time you will have for new ideas…hell who knows! you might even go home and take the rest of the day off with the wife, girlfriend, dog, cat, platypus or if you have a rhino got home and do something nice for it.

Tags: ,

Comments Comments Off

I’ve seen developers do some really wicked stuff when they try to figure out if a char is a digit, and seriously it’s even more simple than you think it is :)

I’ve seen people doing fancy regular expression catching, immense calls to string.TryParse where they cut the string smaller and smaller and afterwards they reverse the string and do it all over.

Seriously look at the following code and nod at the simplicity…

namespace Sleddog.CodeTips.CodeTip001
{
 class Program
 {
   public static void PrintDigits(char[] items)
   {
     foreach(char item in items)
     {
       if(char.IsDigit(item))
         Console.WriteLine(item);
     }
   }

   static void Main(string[] args)
   {
     char[] testItems = new char[] { 'f', 'o', '1', 'o' };

     PrintDigits(testItems);
   }
 }
}

First post is simple but let’s just get started :)

Tags: ,

Comments Comments Off

I put this on Twitter a while ago but! I can’t stop posting this site cause it is oh so awesome for an everyday developer.

The Morning Brew

Kindly presented by Chris Alcock (it’s actually made him an MVP with Microsoft)

Tags: ,

Comments Comments Off

How can I help other developers get even better?

I have read quite a few articles and heard loads of podcasts the last 6-7 months, after I realized how much I was behind on my .NET knowledge. The revelation came as a flash after my first job interview during last summer. I had been given a task to solve a small assignment, so they could look at my code and ask questions on the various topics. I solved the assignment and they were quite ok with it…or well I assume that the flood of questions that followed was to push me, and really find out how my knowledge of the framework was after working with it for 7 years (interview was done by chief architect Dennis Riis at webdanmark.com, seems like a really nice guy and I’m not in doubt that he’s on his toes when it comes to collecting new knowledge). Guess what, I was waaaaaaay behind (or well I have the feeling that there was allot more I could/should have known).

So I have been thinking about what can I actually do to help fellow developers?

Over the years I have been digging around the .NET Framework and tried to use as much of standard stuff as possible. I don’t know it all inside out, but I still see people writing allot of stuff that’s already in the framework. Besides that I see allot of weak/error prone solutions being written, so I’ll try to use my blog in a more useful way than the quarterly blog post. From the start of June I’ll start popping tips to my blog, it’ll be everything from refactoring, codecleaniness, framework knowledge, performance tips etc.

I hope this can make me realize more about what I know…and more important what I don’t know :)

Tags:

Comments Comments Off

Oh dear, all the major browsers have been hacked at a hacker conference…except Chrome. Yes, every freaking nerdy and commoner newsmedia is reporting it…

Guess what, we will only hear about the Chrome part cause “Oh my Google are so awesome”…No they are not! Why wasn’t Chrome hacked…cause nobody took the challenge to hack it. It might be hard to do due to some wicked sandbox’ing, but is this the ultimate browser…not if you ask me. I have it installed on my work laptop but not at home.
First of all I don’t like the UI, secondly the memory footprint is equally crappy to the others. Third and most important…it’s Google, I like their search engine, but just because Google made it doesn’t mean it’s better.

Tags: , ,

Comments Comments Off

It’s no secret that I turned 30 on the 14th of March. It was spend up north in Sweden during my vacation, and it was planned to be that way.

Over the years I have seen many people throwing all kinds of party when they turn 20, 30, 40 etc. So why did I choose to go away from everyone…and not throw a party at all?

The usual patterns as I see them for throwing parties when you turn 30 is as follows:

  1. Last chance to party like hell before people expect you to grown up and buying important stuff like a house … the “oh shit” I have to do allot of important stuff now type.
  2. Last chance for you to throw one hell of a party where you can smash your braincells with the old gang, before they grow up … the I’ll never grow up but you all will.
  3. A nice chance to lean back in the chair and tell everyone that you are the man in control of everything … the look at me type.
  4. A chance to show the family that everything went as they expected, and now you fit into the big boring scheme … the I’m settled just as you wanted type.

Now I take my hat of for anyone that would admit they have done like that, all probably think that they threw a good party and it was all because they wanted to see all their guests. Well honestly I was working on a list of people that I wanted to see, I managed to find a list of roughly 20 people that I actually wanted to spend a fun night with. It would be a mix of very old friends, a few faces from the family and of course people that I just like having around me.

Now why on earth did I wanna leave the country and not throw a party?

Last summer I reviewed my life but already then I had been thinking about disappearing for my birthday, mostly because I don’t really find myself much of a birthday person. Why celebrate your birthday? I see no special reason for gathering the whole family to say “hey I made it another year”. The perfect thing for me when I celebrate growing older is more focused on motivating myself or giving myself some time to go out and start another chapter of life.

So what to giftwrap for your own 30th birthday?

Sledding along with 4 dogs

Sledding the day after my 30th birthday

I have been travelling to northern Sweden for many years now, ever since my cousin “dragged” me up there I have been a frequent visitor at my friends at Mullnäset. Everytime I go there at winter I just get relief of all stress, all worries don’t mean a thing, I get to play around with all their wonderful dogs and last but not least… I get to go out into nature with man and mammal… enjoying the perfect way to move around on the snow.

It was nice being up north… again, now it’s just a matter of time and money before I can start building my own team of dogs, and I know for sure that I’ll be crossing my fingers to get some of the crazy puppies that they’ll supply.

Tags: , , ,

Comments Comments Off

This winter have been fantastic in Denmark, we have had snow from mid-december until now (start-march).

One thing I have learned about the danish people that I wasn’t aware of…they hate snow. I’m not even kidding here, it’s like people have forgotten how wonderful one of nature most fragile elements are. From the very first day when the snow started coming down I just started with a great smile on my face, me and one of my new co-workers even went for a good walk one of the first evenings. We are both quite fascinated by snow and both of us don’t understand the danish people and their desire for bare asphalt :) I know it’s annoying that you have to remove the snow so you don’t get sued by some old cranky mailman that flips over, but where is the memories of great white winters where we could all run around and be like kids again? Since I started visiting my friends in northern Sweden my passion for cold weather have just grown bigger every year, I like walking around in the snowy weather feeling the flakes on my nose, I like feeling the frost bite on my skin. Something about winter and cold weather attracts me more than warmth, I’m pretty sure that the first part is the fact that I can dress up for winter but I can’t undress for summer. At some point you just can’t get rid of the heat and you’ll sit and just be more and more cooked and eventually you’ll just be tired and thirsty from the heat.

I know that people in Denmark are intimidated by frost due to the fact we have frost and real winter so rarely, and when it happens they aren’t prepared with the proper gear. Hell even I don’t have the gear I want when frost is around, this year I have stepped up so I would actually say that it’s not possible for me to freeze during a danish winter (thank you LaCrosse Ridgetop boots).

What to do when winter starts fading away in Denmark? Well, this year I had already planned for a vacation in Sweden for my birthday and with some kinda luck it just fits in now that winter is fading in here :)

Have some fun, enjoy the last wintery strokes in Denmark…remember it’s not illegal to sit inside and enjoy a good dram o’ whisky when the weather outside if frightful.

Tags: ,

Comments Comments Off