What’s New in ASP.NET 4 and .NET 4?

Seems MS are churning out new versions of everything at a pace – or is it just me? Quite often you fall into the trap of just tagging along – when I start a new website now and VS asks me – “do you want this in 3.5 or 4.0” – well I go for 4.0.
Why shouldn’t I? It’s nice to be up to date right? But of course the better question is “why should I?”

Well for the .NET framework it’s of course the case that 3.5 was built on top of the 2.0 CLR, and as such they we’re really just additions to the 2.0 framework (some people have speculated that MS were keen to speed up the advancement of their version numbers (Java EE recently made it to 6), and really 3.0 and 3.5 would have made a lot more sense as 2.1 and 2.2).
The .NET 4 framework however uses a grand spanking new CLR (with some improvements to garbage collections, and changes to allow support for functional programming ao), and a load of additional features to the framework.

Some C# changes include optional and named parameters which essentially allows you to pass only some parameters and/or in any order you like. Also we have a new keyword: dynamic. Basically this switches off type checking for parameters defined as such – so I can for example do this:

		public MyMethod(dynamic someObject)

And the compiler will not attempt to check if someObject does indeed have a DoSomethingCrazy method. This is mainly intended for COM objects, but could also be used for reflection – and tbh could also be misused something awful.
You could start throwing dynamic objects around the place and pretty soon you’d have half of your application outside the compilers type checking – but of course why would anyone ever want to do that? (What could possibly go wrong?)
Kind of reminds me of the var keyword that was introduced in 3.0 – of course as this was just a convenience (the compiler would infer the type from the usage, and perform full type checking on compilation (if not intellisense had picked it up already)) – but it had (has) the same potential for misuse that dynamic does, imho anyway.
The var keyword was needed to support Linq – but pretty soon you saw code all over the place looking like Javascript – which did not really pose any risks – but on picking up someone elses code, the problem is that you have to start doing type inference as well – it’s not just the compiler.
When someone writes var x = GoGetMyThing(); – what do you think x is?
So you sit around hovering your mouse over stuff relying on good old Intellisense to do your job for you.
Anyways – of course as frameworks have to support more and more functionality, the potential for misuse will inevitable increase. And as someone pointed out the other day: I am of course free to programme all my projects in .NET 1.1 if it’s something I feel that strongly about.

With 4.0 we also got an update to the Visual Studio IDE – VS2010 – which besides a very neat design and a new and improved default font (Consolas) – also has some very useful new features.
A really nice feature you should def get to know is the Navigate To – use “ctrl+,” to pop this up. It basically allows you to search through everything, from file names to methods, interfaces – etc, and you can even use CamelCase or abbreviations to narrow your search.
Reference Highlighting is another one of my favourites – hover your mouse over any variable in the code window, and instances of this will be highlighted throughout the document. I’m telling ya – if MS ever removed Intellisense you’d see some stressed MS developers around.
Call hierarchy is an improvement to the “view all references” option – which allows you to see calls to and calls from any method or property. Very nifty when getting to know a new project. Also you can see all implementations of an interface (use this when you do the “go to ref” and you end up looking at the same interface every time) as well as all overrides of virtual and abstract members.
Also there is some improved support for unit testing, including the ability to stub out your code from the unit test that you of course always write before you do anything (don’t you? of course you do).

Moving swiftly along to the core of the matter (for me anyway) – ASP.NET 4.0:


Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: