views:

974

answers:

9

Trying to convince someone to switch from .NET 1.1

I saw people saying that one advantage of using the Dictionary class in post .NET 1.1 is performance increases due to not having to unbox/cast objects. Are there another improvements besides that?

Or any other general advantages to moving away from .NET 1.1 ?

+3  A: 

Assuming you're already aware of the general advantages to using strongly-typed collections, null is now a valid value. If the old HashTable returned null for a key lookup it might mean that the key doesn't exist or it might mean that that key refers to the value null. You didn't really know.

With a dictionary, if you do a straight lookup and the key doesn't exist an exception is thrown.

Also, .Net 2.0 collections take advantage of generics to support strongly-typed enumeration (IEnumerable<T>). The implementation of IEnumerable in .Net uses lazy evaluation, and this makes all kinds of fun things easy (and performant!) that were almost impossible to do before. Probably 9 times out of 10 where you pass or return an array or ArrayList through a function you can use IEnumerable instead.

Joel Coehoorn
this is a good 'feature' also
teriyaki
+16  A: 

George, I can answer that question in two words:

Type Safety.

And now I shall expand. Probably the single biggest benefit of moving to .NET 2.0 is generics and generic collections. A bigger benefit IMO than the performance improvements of not having to box and unbox value types (which isn't really that big a deal unless you've got huge ArrayLists of ints that you process through continuously) is not having to cast to and from object. Or, in two words, "type safety". You know at compile time what the underlying type of the collection is, and you cannot deviate from that. With a non-generic collection, you can throw any old thing in there and unless you reflect on the type (which is an even bigger performance hit than boxing) before you cast, you could wind up with an InvalidCastException being thrown at a bad time.

That said, why stop at 2.0? .NET 3.0 has WCF and WPF, which are great new ways to communicate and present. .NET 3.5 has LINQ and lambda expressions, which will change the way you process a collection.

Tell your friend to stop living in the dark ages. It's time to update!

Randolpho
I (+1) the moment I saw "And now I shall expand." Excellent diction my friend.
Unfortunately, I'm stuck in the dark ages for a while. I inherited a 1.1 project that's tied to a third party component which we don't have for 2.0. (That's actually the least of this project's problems). I'm migrating it as soon as I finish moving it back to standard controls.
codeelegance
Recommendation: migrate sooner rather than later. Anything else can be fixed once you've migrated. You'll be able to fix it using better, more modern tools, with better support. Just get rid of the .NET 1.1 dependencies first. At worse, second, after critical security problems.
John Saunders
I have the same problem as Kenneth. *sigh
teriyaki
+1  A: 

Being strongly typed, the Dictionary<,> is constrained in compile time, and therefore type safe. Attempting to add inappropriate values will result in a compile error.

hmemcpy
+1  A: 

Using Generics can make your Dictionary typesafe, so at compile you'll find code that might be trying to add the wrong object. This is better than a runtime crash due to an unexpected datatype. Also, the enumerator is typed for the data, making it more straightforward to use. The casting of the Current property is no longer needed.

ka3751
+1  A: 

If you're limiting the topic to just generic containers then no. However, .NET 2.0 introduced a number of improvements in other areas as well. See http://msdn.microsoft.com/en-us/library/t357fb32.aspx for a more complete list of improvements.

codeelegance
+1  A: 

This isn't exactly a performance related issue, but how about the IDE? The VS2008 IDE is so much nicer, from stability to features, to add ons... The winForm designers is so much easier to use.

MedicineMan
+2  A: 

Other advantages:

GridView, Masterpages, Sitemap, LINQ!!!! (3.5 framework)

There's no reason that any developer (or company) should continue to write new code in VS 2003, or at least that I can think.

Now, if it's an old project written on the 1.1 framework, then that is a different matter entirely...

Jagd
+3  A: 

When does support for .NET 1.1 cease? Is it already unsupported? What are your chances of ever seeing a bug fix?

In addition, the number of people who know anything about .NET 1.1 is smaller every year. Before long, there will be more people who know VB6 than who know .NET 1.1.

It's past time to upgrade. Unless you still need to support Windows 2000 or below, you don't have many excuses not to do so.

John Saunders
"In addition, the number of people who know anything about .NET 1.1 is smaller every year." That's just because more and more of us are realizing that admitting one knows VS 2003 is a sure-fire way to find yourself suddenly bound to a legacy web app, and by "bound" I mean the sole owner in charge of maintaining.
Jagd
A very good reason why I don't have COBOL on my resume. And I constantly have to explain away the one reference to VB6.
John Saunders
+2  A: 

Making the jump from VS2003 and .NET 1.1 to at the very least VS2005 and .NET 2.0 is well worth the price of admission. Later versions of the .NET Framework after 2.0 seem to be all additive. No or not very many breaking .NET class libraries. They just added new namespaces and classes. VS2008 and from what I understand later versions coming down the pipeline will all support backward compatibility back to .NET 2.0. This makes upgrading your IDE almost trivial (I think you have to convert the projects to the VS2008 project types) and you get the benefits of new IDE enhancements while still using the older versions of the framework. Some of the bigger things that I remember that I enjoy just from VS2008 IDE are the split view when working in ASP .NET, the new CSS windows, and javascript intellisense (VS2008 SP1 I believe on this feature).

Just from personal experience, we did have some issues with Active Reports. We had to upgrade versions of that to work with the new IDE/framework and when we moved from VS2008 from VS2005, some our SSIS package projects didn't open correctly because we are still on SQL Server 2005, so definitely check any dependencies you have on your 2003 IDE with any 3rd party apps you may be running.

Ralphondo is correct though and I would up vote him if I had the rep. Generics are a game changer for sure and prevent you from having to create typed collections on your own to have type safety. Seriously.... google search what you have to do in .NET 1.1 vs later versions. The difference is night and day.

sdanna