RSS
Facebook
Twitter

Saturday, February 28, 2009

Where are all the VB.NET blogs – an update

In my last post Where are all the VB.NET blogs? I commented that it seems like the amount of VB.NET specific information on the web has dwindled since the .NET 1.x days. Well it seems that at least the number of VB.NET developers has not.

A friend has sent me a link to a post: My analysis of the recent Visual Basic Survey + an extra graph :-) that was written by Arik Nelson - a VB.NET blogger!

He has done a survey on usage of VB6 & VB.NET in the UK and has some interesting results – it seems that there are still many VB6 developers out there and they are here to stay :)

Under the section VB & C# he states that although C# is more popular VB.NET is widely used in the UK and is the preferred language of developers with previous VB6 experience (surprise).

Having said that I still feel that there is a shortage of VB.NET information on the web – most blogs I see are C# centric and so are most of the coding examples I find when I look for new information.

image

[Thanks lpe - for suggesting Google trends]

 

The only question is: do I look only in the wrong places or why all those VB.NET developers aren’t posting information for the VB community.

Feature Image

Wednesday, February 25, 2009

Where are all the VB.NET blogs?

When I started learning .NET I learnt mostly by reading examples and tutorials I found on the internet, I read sites such as Code Project and .NET 247 from front to back and found several blogs that eased my way into the .NET world.

During my quest to become a good .NET developer I came across many examples and tutorials written using VB.NET, in fact I learnt to code in VB just so I can read them and won’t be limited to “C# only” information. At the time it seemed to me that there was a 50/50 ratio between C# and VB information on the web.

At the beginning of the .NET era (1.x) it seems that the .NET world was split to two different “camps” - Developers with previous C++ experience mostly preferred C# while software developers from the VB6 world found VB.NET more to their liking. I remember that one of the most debated topic of that time was which language is better C# or VB.NET (BTW - I think that neither one).

Nowadays it seems that the .NET posts I find on the web are mostly C# oriented, could it be that VB programmers decided to finish the C#/VB feud by becoming C# developers or did they just stop writing?

I confess – I prefer C# mostly because I write code faster using it, after years of C++ It is the programming language I think in. But obviously there bound to be software developers with previous Visual Basic (or Delphi) background that prefer VB.NET from the same reason.

Then why is it that when I posted a question on StackOverflow about the preferred .NET language for programming not one answered “VB”?

One can argue that perhaps most users of StackOverflow are C# developers and a proof of that there 1-10 ratio between questions tagged with VB (1363) to those tagged C# (12405). Even if it’s true - where do VB’ers go to discuss their issues and and when was the last time you actually saw VB.NET blog?

Has anyone else noticed this phenomenon?

Monday, February 23, 2009

Presentation from .NET Software Architects User Group

Yesterday I co-delivered a lecture about Unit testing titled "How to benefit from unit testing in the real world" at the monthly gathering of the .NET Software Architects User Group.

image

I'd like to thank Doron that presented the 2nd part of our lecture and give thank to an esteemed member of our development team - the build bunny.

We had a good turnout (50+ people) that came to hear about TDD and Unit Testing.

The presentation went well with only one notable incident (the movie we had didn't show well).

Both myself and Doron enjoyed ourselves immensely. We had fun talking with the listeners and we even managed to learn a bit from the audience.

 

If you're interested in Unit testing, TDD and how your development process can benefit from using agile methodologies have a look:

Update:

In the presentation I used information about TDD effectiveness I found at MS Research.

The research paper can be found at:

Microsoft Research: Realizing quality improvement through test driven development: results and experiences of four industrial teams

Wednesday, February 18, 2009

Use measureIt to find out how much time it really takes

I've been interested in performance optimization from the first application I wrote and since than I been finding new ways to make my code run faster with less memory usage. Over the time I found that after discovering the existing bottlenecks in the code knowing which command takes more time to execute is always an easy win when in need of optimizing a specific code.

There are several ways to find the performance implications of different code snippets - writing a benchmark, searching the Internet and one of my favorites using measurIt.

This simple tool written by Vance Morrison from Microsoft's .NET runtime team runs several well used .NET snippets and outputs the time it took to run each snippet.

For example acquiring ReaderWriterLock takes more time then using simple lock/Monitor.Enter:

image

Using measureIt saved me some time and should help resolving the known argument of which command takes more time.

Tuesday, February 10, 2009

TestDriven.NET 2.19 Released

There are some development tools that after a while I can’t understand how could I work without them. One of those tools that I’ve been using since I’ve staed software development in C#/VB is TestDriven.NET.

For those of you that never heard of TestDriven it brings integration of several 3rd party tools to Visual Studio, And for me using NUnit without it is just not as agile as I need it to be. And the really great thing about TestDriven is that it is completely free for non-commercial use.

Today Jamie (the creator of TestDriven.NET) announced the newest version that has quite a few new tool integration and features.

As always TestDriven.NET enables Visual Studio integration with the following tools:

So if you’ve never used it give it a try, or in case you’re a long time user like myself – download the latest version of TestDriven.NET today!

Thursday, February 05, 2009

Three different ways to raise events in C#

The Event model in C# finds its roots in the event programming model that is popular in asynchronous programming. The basic foundation behind this programming model is the idea of "publisher and subscribers." In this model, you have publishers who will do some logic and publish an "event." Publishers will then send out their event only to subscribers who have subscribed to receive the specific event.

In C#, any object can publish a set of events to which other applications can subscribe. When the publishing class raises an event, all the subscribed applications are notified. The following figure shows this mechanism.

From Delegates and Events in C# / .NET

Using events is C# is easy – all that is needed is to add a handler method and attach it using ‘+=’. It is a common practice in a class that declares the event to check if anyone is listening on it using a simple If block:

if(eventWithIfBlock != null) 
{ 
eventWithIfBlock(this, EventArgs.Empty); 
}


It isn’t very elegant but it works and could be refactored to a function in case the event is needed to be thrown from multiple places in the code.



But there are more elegant ways to handle the problem of event not having any listeners.



Using empty delegate (.NET 2.0)



One trick I learnt (but didn’t invent) is using an empty anonymous delegate as a “default listener” so that the event would never be “null”:



public EventHandler eventWithEmptyDelegate = delegate{};


It is a simple and elegant solution that makes sure that our code would never throw a NullReferenceException due to no one listening on the event.



Using Extension Methods (.NET 3.5)



I found this cool trick in Michel Grootjans’s blog in Elegant way to raise an event.



It is a simple improvement of the basic if block by adding an extension method Raise() the event type class:



public static class EventHandlerExtension
{
public static void Raise(this ClassWithEvents.EventHandler eventToThrow, object sender, EventArgs args)
{
if(eventToThrow != null)
{
eventToThrow(sender, EventArgs.Empty);
}
}
}


And then throwing the event is very simple and elegant:



public void ThrowEventUsingExtensionMethod()
{
eventWithExtensionMethod.Raise(this, EventArgs.Empty);
}


Performance considerations



All is nice and well but what if many events throws happens during the execution of the code, is there a preferred method performance-wise?



I’ve wrote simple program using Stopwatch to check what is the performance cost of using each of those methods.



In the test calls each event 1M times and then connects a listener method and calls then event one million times more.



The results are:



image



Let me explain the results – it doesn’t really matters! whatever method you choose the price of calling each of the method 1M times is less then a 0.2 of a second.



Although a simple comparison shows that using an empty delegate (method #2) takes a bit more time then the other two methods but I doubt it would effect the overall performance of an application.

Wednesday, February 04, 2009

Typemock Isolator is in Visual Studio Gallery

In case you've never been to Visual Studio Gallery - it is a "one stop shop for Visual Studio extensions. It includes everything from community built power toys to advanced industry partner...".

This site is a great resource of visual studio extendibility, you can find many of the tools that most software developers use on their daily work as well as less known extensions.

Typemock Isolator is also featured in Visual Studio Gallery - you can see our product page here.

Feel free to review and post comment about your experiences using Typemock Isolator

Oh, and if there is an extension there you think people should know about - write about it in the comments, will you?

Related Posts Plugin for WordPress, Blogger...