On June 9, 2008, yes I am behind on this one, Ilya Ryzhenkov announced on the ReSharper Blog, that ReSharper 4.0 has been released. This release includes full support for C# 3.0, lambdas, extension methods, LINQ, object and collection initializers, anonymous types, automatic properties and partial methods. Check out a more complete list on the New Features page.
I have downloaded and installed the this version and am loving the full Visual Studio 2008 integration. The one thing that I might argue about is the implicitly typed locals (“vars”). I haven’t made up my mind on these yet. I will have to re-wire my thinking, since I always think about the old Visual Basic Variant type and shiver.
I still believe that ReSharper is a must have for any developer coding in reverse or using any of the *DD, (TDD, DDD, BDD) styles of development.
JetBrains has released ReSharper v4.0 Beta for VS2008, I have been running the nightly builds for a while and am glad to see the beta realase. I have already downloaded and installed it, and like the nightly builds it appears very usable.
Some new features in ReSharper 4.0:
- Full support for C# 3.0 and LINQ
- New code analysis, context actions and quick-fixes
- New refactorings (such as Convert to Extension Method, Convert to Automatic Property, Convert Anonymous Type to Named)
- Complete Statement, Ctrl+Shift+Enter
- CamelHumps in Code Completion
- Live Templates Editor & Manager
- Recent Edits
- ASP .NET speed ups
Pick up the ReSharper 4.0 Beta for VS2008 here http://www.jetbrains.com/resharper/beta/beta.html.
If you are like me you don't want to go a day without it.
I recently learned about a very cool option in Visual Studio, the ability to extract an Interface from an existing class. This has made me much more comfortable in trying to adhere to a principle of not creating unnecessary code. I often found myself thinking I should create an interface first before creating the concrete implementation even for objects that I didn't have any current plans for extending.
This post will show you step by step how to extract an interface from an existing class, so keeping with open closed principle we can still extend the code base with our modifying the current object.
First lets consider the the Attendee class.
namespace Attendee
{
public class
Attendee
{
private int _age;
public int Age
{
get { return _age; }
set { _age = value; }
}
private string _firstname;
public string FirstName
{
get { return _firstname; }
set { _firstname = value; }
}
private string _lastName;
public string LastName
{
get { return _lastName; }
set { _lastName = value; }
}
public bool Save()
{
return true;
}
}
}
This is a very simple class implementation of an Attendee, a class I use in my Model-View-Controller presentation. Note this is a very simple domain object with no logic. To extract an interface place your cursor in the class name, Attendee in this case, select Extract Interface... on the Refactor menu.
This will launch the Extract Interface wizard. We can now modify the name, file name and the members to include in the interface.
Clicking OK after making your selection will generate the interface below.
using System;
namespace Attendee
{
interface
IAttendee
{
int Age { get; set; }
string FirstName { get; set; }
string LastName { get; set; }
bool Save();
}
}
Now you are free to create a new implementation of the Attendee class with out having to change any of the code in the old Attendee class. This has really reduced the fear of not creating an interface for everything first. Of course I still do for most of my objects but if there is no reason to create it right now, this give me the confidence that I can defer creating the interface and extension point until it is necessary.
If you haven't made the jump to Visual Studio 2008 cause you don't have the bits, give a virtual PC a test drive. Microsoft is offering pre built virtual PC with several Visual Studio configurations. These are a perfect way to get a look at Visual Studio 2008 and not have to install it on your local machine. This can also be great for creating presentations.
Check out the full listing of Virtual PC Microsoft has made available pre installed with Visual Studio 2008 here: http://msdn2.microsoft.com/en-us/vstudio/aa700831.aspx These Virtual PC images will work until April 1, 2008, so that should give you plenty of time to play around.