Archive for July, 2008

h1

VB Extension Methods > C# Extension Methods =(

July 31, 2008

As my title childishly explains VB extension methods seem to have one over c# extension methods. Yesterday I found the following limitation in c#: You cannot modify the object you are calling the extension method on by ref. you must create a copy of the object and pass it as a return value. An example will make this clearer. You CAN do this:

public static IEnumerable<T> AddRange<T>(this IEnumerable<T> list, IEnumerable range)
{
List<T> totalList = new List<T>();

foreach (T t in list)
{
totalList.Add(t);
}

foreach (T t in range)
{
totalList.Add(t);
}

return totalList;
}

You can NOT do this

public static void AddRange<T>(this IEnumerable<T> list, IEnumerable range)
{
List<T> totalList = new List<T>();

foreach (T t in list)
{
totalList.Add(t);
}

foreach (T t in range)
{
totalList.Add(t);
}

list = totalList;
}

It’s a sad day today my c# friends ;p

Advertisements
h1

WPF Findings

July 28, 2008

Here at work I am currently on my first commercial WPF project. Some of the things that I have learnt about wpf (the hard way)

* There is no Paging or Sorting support in the gridview (unbelievable isn’t it?)

* There are no validators!

* The WPF Binding Engine uses reflection when binding against Dependency Properties and as such your properties need to be public. If not, you will get a silent exception in the output screen

* When binding to a dropdown list ComboBox you cannot bind against a nullable int. Why? I have no idea, but you will find that the selected index changed event will not fire

* There is no Gif Animation Support in the Image control. (expected to be supported in next release of wpf)

I have quite a few more points but they were the top few that I could think of that were easy to list out.

Overall I am loving what WPF has to offer and it is quite a different thinking approach as to web development. Although I must admit I feel a bit home sick (asp.net)

h1

Unit Testing Internal methods.

July 10, 2008

Today I did some pair programming with Richard Banks from Readify.

When I explained to him that I use the IDE to generate these property accessors that use reflection to test internal and private methods he showed me a nicer way around it:

  http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute.aspx

Basically all I had to do was [assembly: InternalsVisibleTo(“Assembly Name”)] to the assembly.cs file and make sure that the “Assembly Name” was pointing to the unit tests assembly name.

This worked perfectly! Thanks Richard!

P.S I should state the obvious note that this approach doesn’t work for private methods

h1

Frustrated and Disappointed.

July 1, 2008

<frustrated rant>

So on Monday night, a project that I have been working on for 3 months goes live. The project it self was very exciting and fun but unfortunately, it was managed very poorly and as a result, had scope creep and was not finished in time. It was not ready to go live yet it was rushed and tightly managed by Business Analysts and IT General Managers to ensure it still went out and made the deadline. Towards the middle of the project I had raised my conerns many times to the relevant business sponsors but it was ignored. Now, the applications launch (although it was reasonably successful) has lost a lot of credability because it keeps erroring. There have been over 1 million hits to the website with about a 60% error rate/unacceptable user experience. They have had an enormous amount of purchases made through the online store but I don’t think they realise (or chose to care) about the fact that those numbers could have been doubled. It is a frustrating feeling when IT Managers don’t choose to accept the advise of IT Professionals around them. I believe it is called micro managing. I strongly believe an Agile environment would solve these issues I have been experiencing as of late.

</frustrated rant>