Friday, 26 September 2014

10 Features in .NET 4.0 That Made Me Smile


by Michael Kennedy

I have been reviewing some of our upcoming classes at DevelopMentor this week. One of those classes, What’s New in .NET 4.0, left me excited for things to come. 

There are a bunch of small but wonderful features discussed in that class. I thought I’d take this opportunity to write a few of them up and share the joy.  I bet some of them make you smile too.
  1. The Parallel Extensions for The .NET Framework will be built into mscorlib.dll. 

    The fact that PFx will be part of the core .NET library says a lot about how much faith and support it’s getting within Microsoft. BTW, here are some really great demos for PFx in .NET 4.0
     
  2. PFx introduces a new threading construct: Barrier<T>. 

    Barrier lets you define rendezvous points in your code where multiple concurrent operations can automatically sync-up. Here’s an example
     
  3. Code contracts.

    Code contracts allow you to assert truths about your code as if you are writing a unit test. But these assertions live within your production code and are both verified by the compiler as well as the runtime. Here’s the original research project that lead to this feature on Microsoft Research.  
     
  4. The WPF and Silverlight designers mostly work.

    Now this shouldn’t be a point to make me smile or get excited about, but it is. The pain and suffering around the Visual Studio support for WPF and Silverlight designers has been so bad that a mostly-working, and sometimes truly innovative design-time experience within Visual Studio gives me real hope for these technologies. I’m actually excited about them now. 
     
  5. Support for the MVVM pattern across both WPF and Silverlight.

    Speaking of that XAML stuff, if you write WPF or Silverlight code and don’t know MVVM, stop reading this article and tp://msdn.microsoft.com/en-us/magazine/dd419663.aspx" target="_blank">learn about it here. I’ll wait. Ok, now you too should be excited to hear that there is improved support for MVVM across Silverlight and WPF in a unified way. Smiles baby! 
     
  6. WF (Windows Workflow Foundation) has an AsyncCodeActivity class.

    If you have looked at long-running workflows in .NET 3.5 you know they were hard. I even wrote about them. WF 4 has a class which has a BeginExecute / EndExecute pair of methods which much more closely models the regular .NET async design patterns. 
     
  7. WF has a rehostable designer (really, they mean it this time).

    There are some great uses for giving regular users a WF designer experience with the right granularity of activities. Now it’s much easier. Here’s an app that rehosts the designer: 

  8. Configuration-free WCF Hosting.

    WCF services is now like hosting ASMX web services if you like the defaults. Just throw out a server + contract + address and it’s up and running. That’ll save a bunch of <system.servicemodel> configuration goo. Smiles! 
     
  9. No more *.svc in our RESTful urls in IIS.

    With the ASP.NET routing framework and WCF REST introduced in .NET 3.5, we can create beautiful, expressive Uri’s for our websites. For example:

       http://lookatthiswith.me/watch/intro 

    But this falls apart with WCF REST when we host it in IIS. Our service Uri’s look like this: 

       http://lookatthiswith.me/services/lookieservice.svc/lookup/json/cf7 

    And now we have this ugly .svc part-way through our Uri! Ick. Well, in .NET 4 that Uri is much more customizable and the .svc is gone. Smiles! 
     
  10. ASP.NET MVC has wicked JavaScript support.

    JQuery is there by default. That’s awesome. But there is also a class similar to the Html class (for HTML helpers) called Ajax. This static class has functions like Ajax.ActionLink and effectively brings the functionality of UpdatePanel to MVC!

Well there you have it. 10 features in .NET 4.0 that made me smile this week.  I hope you find some to be welcome additions yourself! If you want to learn more about .NET 4.0, check out our recorded Webcasts here: http://www.develop.com/dotnet4webcasts

Also have a look at my article from last month Six Things That’ll Surprise You About .NET 4.0. Finally, if you have some training funds laying around, I’d love to spend a week talking about these ideas with you in our What’s New in .NET 4.0 course.

Michael Kennedy is an instructor for DevelopMentor where he specializes in core .NET technologies as well as agile and TDD development methodologies.  Keep up with Michael via his Web site and blog at http://www.michaelckennedy.net or on Twitter: @mkennedy.

No comments:

Post a Comment

Angular Tutorial (Update to Angular 7)

As Angular 7 has just been released a few days ago. This tutorial is updated to show you how to create an Angular 7 project and the new fe...