2009-12-09

Ignore whitespace in TFS compare

http://adventuresinsoftware.com/blog/?p=330

image

Command: C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\diffmerge.exe

Arguments: %1 %2 %6 %7 %5 /ignorespace

2009-07-15

Timelock

IanG on Tap: Oh No! Not the TimedLock Again!: "Oh No! Not the TimedLock Again!"

This code shows how to do locks with timeouts and a way to check if someone forgot to call Dispose on a IDisposable struct.

2009-07-08

C# Object Initializers. More than meets the eye

Up till today I liked C# object initializers because the looked nicer and when using parameter objects they even turn into something like named parameters.

But just a couple of minutes ago I was changing some test data creation code that didn't use object initializers but plain property assignments.

As I use ReSharper I alt-returned the assignments into an initializer. What struck me was that not all property assignments where put into the initializer.

Why? Because the same property had two assignments (of course with different values). I only noticed that when I was trying to incorporate the assignment into the initializer and the red squiglies from ReSharper. The C# compiler issues an error when you try to compile this type of code:
error CS1912: Duplicate initialization of member 'X'
So object initializers not only look better, they prevent you from making such a dumb mistake.

2009-07-06

Cool Solutions: Ninotech Path Copy 4

Cool Solutions: Ninotech Path Copy 4

Preparation for 3rd meeting on C#iD: Nullables

Once again: There are still lots of things I do not know about the CLR. I find it more shocking on each occasion.

  • I was not aware of the GetValueOrDefault method on Nullable. Never used it.
  • Boxing/Unboxing of Nullables: 4.2.2 pp 118, 119: I had no idea that this might be an issue. But that boxing an instance of Nullable results in either a null reference or a boxed value of the underlying type does make perfect sense.
  • The class Nullable. Never used it as well. But I should have used the GetUnderlyingType method. I firmly believe that I have implemented exactly that feature two or three times in the last couple of years in various project using reflection.
  • No supprise about the null coalescing operator. But I notice that it is one of the lesser known features of C#. My estimation is that 2 out of 3 devs do not know it.
  • Using Nullable for trying an operation: That idea is brilliant. Why didn't I thing of it? I used it right away.
  • Combining Comparers by using Nullable as the return type and than applying the null coalescing operator is a very cool thing especially regarding the readability/maintainability of the code.
Regarding the last topic I was thinking on how we would implement to allow the end user to create a sort expression by combining individual comparers. That still does not get any better with the solution presented in C#iD (to be fair: it never claimed to solve such a request, but I find it still interesting).
My first idea was to have each comparer have a reference to a NextComparer to which it would delegate if it's own result would be 0 (zero). That would allow us to chain together comparer in any sequence we like at runtime. It would be something like a Chain of Responsibility.
What I do not like about it is the fact that now the Comparer have to compare and have to handle the chaining as well. So I think having Decorator for the comparer that will take care of the chainging, the delegating to the next element of the chain and will decide how to handle the end of the chain would be much better.

2009-06-24

Follow up for the second c#ID Study Group Meeting

Very good discussion arround generics. It is baffling how you gain insight when trying to explain something.

I've found that most developers don't now the concept of single, double and multiple dispatch.
I strongly recomment to read up on this:

2009-06-22

Preparation for the second meeting of the c#ID Study Group Würzburg

The last meeting has been quite a long time ago because one of us three took a vacation of a couple of weeks. So here we are back again.

The topic of this meeting is chapter 3: Parameterized typing with generics.

As I am now in my 4th year of developing with C# 2 there have been few really new and stunning facts in this chapter. Still I’ve learned quit a good bit and I was able to pick up quite a couple of terms that help me clarify my understanding of how generics work.

Here are the main points that were very valuable to me:

  • The diagram on page 68 is really an eye opener as it explains the relationship between unbound generic types, constructed (generic) types and instances. I wont put a copy of this diagram here. Go get the book!
  • The way the runtime constructs a type from an unbound generic type for each different combination of the generic parameters.
  • The way comparison are performed with the == and != operators based on the constraints on the generic type parameters as explained on pp 82, 83.
  • Very interesting is the demonstration on page 87 that each constructed type has its own static constructor .
  • I cannot remember finding any hint, that there are no generic methods in C++. Which is obvious if you look at how templates are a king of "preprocessor on steroids". The generic parameters of generic methods are only available at runtime (are they really?) but not at compile time.
    Which leads me to another question: Are generic parameters of methods resolved based on the runtime or on the compile time type?
  • OMG: Covariance and Contravariance again!
  • On p. 103 the options for working arround the invariance of generic types. The last item talks about a generic helper method to convert the items in a collection. Here should be mentioned that there is a method System.Linq.Enumerable.Cast(IEnumberable) that does just that. I think a hint would be in order even if this C# 3 features are dealt with later in the book.

2009-05-14

What Every Computer Scientist Should Know About Floating-Point Arithmetic

Pointed to by Coding Horror blog.
I should read that some time.

What Every Computer Scientist Should Know About Floating-Point Arithmetic: "What Every Computer Scientist Should Know About Floating-Point Arithmetic"

2009-04-29

Using Launchy to take quick notes

I've added an entry to Launchy's Runner plugin to take quick notes.
I just type tn someText and the someText gets appended with date and time stamp to the file c:\notes.txt.

The item is defined like this:
Name: tn
Program: cmd.exe
Arguments: /C "echo %Date% %Time%>> c:\notes.txt & echo $$ >> c:\notes.txt & echo_>> c:\notes.txt"

WinXP Batch for Exporting Balsamiq Mockups to Pngs

@echo off
rem Export all Balsamic Mockup files to pngs in the same directory.
setlocal
if not "%echo%"=="" echo %echo%
set prog="%ProgramFiles%\Balsamiq Mockups\Balsamiq Mockups.exe"

for %%m in (*.bmml) do call :ProcessFile "%%m"

exit /b

:ProcessFile
rem must provide fully qualified paths of balsamiq
%prog% export "%~f1" "%~d1%~p1%~n1.png"

Edit 29-Apr-2009 13:10 (EDST)
Peldi asked my to include a link to the Balsamiq support site
and I hereby oblige happily. I should have looked there first - I just enjoy to much writing shell scripts.

2009-04-19

Ideas for Lego Mindstorms projects

Today has been my son Viktor’s ninth birthday. He is a rather bright kid with a keen interest in everything that you have to build on your own. I would say he is a natural geek.

As I am not so proficient in handy work my wife and me decided on a LEGO Mindstorms NXT set for Viktor as this years birthday gift. That way I might be able to help him with his projects.

As I am sitting in my train back to my job back to Wurzburg to my software contracting job and reading “The unofficial LEGO MINDSTORMS NXT Inventor’s Guide” I come up with some ideas:

  1. Building a robot that will write messages by pouring sand (maybe colored)
  2. Sending those messages via Bluetooth (from a mobile phone?)
  3. A device that will squirrel of to the darkest corner of the room as soon as it detects someone entering the room. The device already has a name: Scarry Frank.

2009-04-08

Creating UI Mockups. Focus on Essentials: Balsamiq Mockups

I've been starting a new job as a contract developer recently. I explicitly statet that I am not a "GUI guy". But people just don't listen. I ended up with the task of designing a UI for an app.
Initially I was told to do the screen design in ... Enterprise Architect. Well that what they use in this shop, so I went along with it.

The problem: You can almost do screen design. But there are a lot of things you can do much better in EA: Class diagrams, sequence diagrams, you know it. So I ended up with a sloppy screen design that had few essential details in it and a bunch of real UML diagramms that the users couldn't care less. One user remarked: "Is this app gona run on Windows 3.11. The screens just look like it."
Well, when all you have is a hammer...

Then I remembered a tool whose main purpose was to do screen mockups. Its called Balsamiq Mockups. It is an Adobe Air application. So it runs on almost anything you can think of: Mac, Windows, Linux. The even have plugins for a couple of Wikis like Confluence and the like.
What took me a week with EA, I could redo in a day with the suggestions I got from the users. There are two reasons I can think of that made it so quick:
  1. It was the second time arround for me.
  2. Balsamiq Mockups focuses on screen mockups and nothing else.
I do not want to say that EA is a bad tool. It was just not the right tool for the job at hand.

So what I did is buying a license for Balsamiq Mockups Desktop and churned out screen designs like there is no tomorrow. Yes I bought the license myself, yes I installed unauthorized software on a company machine, yes I am dumb and I am guilty. But I just can't stand to being slowed down by some not so inspired company policies. If I get fired for this, I'll complain to Balsamiq.

The designs included a lot of tree views and what really hooked me for Balsamiq was the ease I could mock up tree view by entering text. Before that I was doing those mocks in Visual Studio by creating a form and mangling the controls on it until it looked right. I already told you that I am dumb, didn't I?

Here is a simple screen mockup that I created (not from my job at the company):

(Sorry for the bad image quality. It's the first time I uploaded an image to my blog.)

As you can see on the left hand side there is a tree view. To create that tree view I just had to enter
F My Library
.>Books
.>Music
.>Videos
F Other's
.f Daniel
..>Books
.f Elke
..>TV
.f Susi
..>TV
..>Music
I wont go into the syntax. You can just look it up on their web site.

What really got me when I showed the stuff to my co-workers. Me the non-gui guy comming up with screens like I was some turtle-neck wearing design type.

First voices are heard about doing all the screen designs with this tool and buying some licenses.

2009-04-03

Assembly generation failed Referenced assembly ‘xxx’ does not have a strong name

Assembly generation failed Referenced assembly ‘xxx’ does not have a strong name: "Assembly generation failed Referenced assembly ‘xxx’ does not have a strong name"

How to sign an assembly you do not have the source code for.

As I am reading this on 3-April I just make sure that it was posted not three days ago but in the middle of march. That is just incredible: A two line solution to a problem I thought was hard.

2009-03-22

Getting started with Boodhoo BDD | Sleep Overrated

Maybe with his help I might finally grok it.

ReSharper Templates | ThoughtShapes

Some ReSharper Live Templates

It is somewhat dated by I find recreating the ones used for unit testing all the time. So finally I have a link to the original post.

VI style short cut key defs for ReSharper

Jean-Paul S. Boodhoo's Blog - ReSharper Helper – AutoHotkey Script

These are VI style short cut key defs for ReSharper

Move Down A Method Alt-J
Move Up A Method Alt-K
Move Method Up Control-Shift-Alt-K
Move Method Down Control-Shift-Alt-J
Go to next usage Shift-Alt-J
Go to previous usage Shift-Alt-K
Generate Code Alt-I
Highlight Current Usages Alt-8
Find Usages Alt-9
Next Error In Solution Alt-0

2009-03-21

download : vim online

download : vim online
This is the version for Windows

Jean-Paul S. Boodhoo's Blog - BDD AutoHotKey Script Update - Take 2

Jean-Paul S. Boodhoo's Blog - BDD AutoHotKey Script Update - Take 2

Visual Studio Settings

These VS 2008 Settings (hope no one takes offense in this rs link) include:
  • Consolas as font
  • Keyborad shortcuts for TestDriven.Net (runtest, debug, rerun, rerun with debug)
  • Show line numbers
  • Switched off outlining
  • Minimal Toolbar
Realy need to add a post for Resharper live templates

AutoHotkey Download

AutoHotkey Download

JSON Viewer - Home

JSON Viewer - Home: "JSON Viewer"
Includes stand alone application as well as a debug visualizer for Visual Studio and a Fiddler add in.

PowerCommands for Visual Studio 2008

So finally I will use this as a note to self thing.
Never forget it.

Whos.amung.us?

whos online

Ralf"s shared items