Scott Wojan

DotRant BLOG
posts - 19, comments - 66, trackbacks - 5

My Links

News

Archives

Post Categories

Image Galleries

Wednesday, December 12, 2007

Visual Studio 2008 & .NET 3.5 Quick Changes Overview

Visual Studio 2008 & .NET 3.5 Quick Changes Overview
I AM NOT TRYING TO REPRESENT THIS WORK AS MY OWN, I AM MERELY AGGRIGATING EXISTING INFORMATION HERE FOR MY OWN BENIFIT AND MAYBE YOURS
Visual Studio 2008
General
·         Can target framework versions 2, 3, and 3.5
·         Built in ORM
ASP.NET
·         Now supports nested master pages in the designer
·         Faster switching between markup and designer
·         Split view for seeing the designer and markup at the same time
·         Drastically improved CSS support with new “Manage Styles” property window
·         ASP.NET AJAX 1.0 is now baked in
·         Built in JavaScript intellisense
o   C# style code comments for additional information via intellisense
C# Language Changes
·         Automatic Properties
o   No longer required to have a private member variables and public getter/setters. The compiler figures out what is meant by the new syntax and automatically generates it for you in the resulting IL.
Traditional Way
New Less Verbose Way
public class Person
{
    private string name;
    public string Name
    {
        get { return this.name; }
        set { this.name = value; }
    }
}
public class Person
{
    public string Name { get; set; }
}
 
·         Object Initializers
o   No longer have to build constructors for every possible way you want to initialize the object.
Traditional Way
New Less Verbose Way
public class Person
{
    private string name;
    public Person()
    {
    }
    public Person(string name)
    {
       this.name = name;
    }
    public string Name
    {
        get { return this.name; }
        set { this.name = value; }
    }
}
public class Person
{
    public string Name { get; set; }
}
//*notice no constructors are defined
Person person = new Person();
person.Name = "Scott";
 
//   -- or –
 
person.Name = new Person("Scott");
Person person = new Person();
person.Name = "Scott";
 
//-- or –-
 
person = new Person{Name = "Scott"};
//Note the use of curly braces   ^
 
·         Collection Initializers
List<Person> people = new List<Person>();
people.Add(new Person("Frank"));
people.Add(new Person("Dean"));
people.Add(new Person("Sammy"));
List<Person> people = new List<Person> {
        new Person { Name = "Scott"}
       ,new Person { Name = "Bill"}
       ,new Person { Name = "Susanne"}
};
 
·         Extension Methods
o   Allows developers to add new methods to existing CLR types.
Traditional Way
Using Extension Methods
namespace Validation
{
 public static class Validator
 {
  public static bool IsInt(string s)
  {
  Regex regex = new Regex(@"^[-+]?\d*$");
  return regex.IsMatch(s);
  }
 }
}
 
using Validation;
if (Validator.IsInteger(textBox.Text))
{
 //Do Something
}
namespace LanguageExtensions
{
 public static class StringExtensions
 {
 public static bool IsInt(this string s)
 {
  Regex regex = new Regex(@"^[-+]?\d*$");
   return regex.IsMatch(s);
 }
 }
}
 
using LanguageExtensions;
if (textBox.Text.IsInt())
{
 //Do Something
}
 
·         Anonymous Types
o   A variable’s type is inferred from its initialization
Traditional Way
Using Anonymous Types + Object Initializers
Person person = new Person();
person.Name = "Scott";
var person = new Person{Name="Scott"};
 
·         Lambda Expressions
o   A less verbose way of accomplishing anonymous methods which were introduced in 2.0
Traditional Way
Using Lambda Expressions + Anonymous Types
List<Person> people = new List<Person>();
people.Add(new Person("Bob"));
people.Add(new Person("Bobby"));
people.Add(new Person("Susanne"));
 
List<Person> filtered = people.FindAll
(
    delegate(Person p)
    {
        return p.Name.StartsWith("Bob");
    }
);
List<Person> people = new List<Person> {
        new Person { Name = "Scott"}
       ,new Person { Name = "Bill"}
       ,new Person { Name = "Susanne"}
};
var filtered2 = peeps.FindAll(p => p.Name.StartsWith("Bob"));
 
·         LINQ (Language Integrated Query)
o   LINQ is the attempt of adding the expressiveness of SQL to .NET languages
Traditional Way
Using LINQ Query Syntax
List<Person> results = new List<Person>();
foreach (Person p in people)
{
    if(p.Name.StartsWith("Bob"))
    {
        results.Add(p);
    }
}
 
//   -- or –
 
List<Person> results = people.FindAll
(
 delegate(Person p)
 {
    return p.Name.StartsWith("Bob");
 }
);
var results =
    from p in people
    where p.Name.StartsWith("Bob")
    select p;
o   Additional Examples

Posted On Wednesday, December 12, 2007 11:04 AM | Feedback (5) |

Fasten your seat belts, turbulence ahead...

So I was just reading this post by ScottGu outlining what is in store for 2008 and my head started spinning and I got faint.

<rant>
Did I read " ASP.NET MVC"??  Microsoft is now going to provide an MVC framework for ASP.NET instead of their dumb arse postback method?  Guys, the java camp was doing this with struts almost EIGHT YEARS AGO!?! Why didn't you do this out of the box!?!?!
</rant>

Whew, sorry for that... back to my question...
Is it just me or do you also feel like your are getting left in the dust with all the changes that came out in the past year and what is in store for 2008?

Posted On Wednesday, December 12, 2007 11:00 AM | Feedback (3) |

Powered by: