Microsoft’s marquee development tool is poised to make some great strides in
making .NET developers even more productive than they are already today. Though
it is still only Beta 1 and MS does not plan to release the tool until late
2010, there is a significant numbers of features that appeared to be production
ready (along with a few that are currently promised for Beta 2).
Looking around
On first glance there is something different about the UI/UX. It may be that
the graphics team is still cleaning up the look and feel or it could be that the
IDE is written using WPF. Either way it definitely needs a bit of refinement in
my opinion. On the bright side the new tool will support dual monitors.
If you into test driven development there is a whole new menu section
dedicated to TDD. I haven’t had time to look at the particulars, but it is
encouraging to see some MS effort in this space.
Extension Manager promises to be beneficial by providing sample project
templates, directly from the IDE, that follow best practices guidelines.
Help is more helpful by linking to Sample Applications from MSDN
directly.
Coding Is King
One of my favorite IDE shortcuts is the new “Generate Class From” context
menu that allows you to write a declaration like below you can right click on
the NewObject() and choose “Generate Class From”. This will create a new class
file using the object name and create the stub for the class. Additionally you
can right click on the Methods and generate the method stubs, including
parameter types, for each method.
NewObject newObj = new NewObject();
newObj.FirstMethod();
string new str = newObject.SecondMethod(5);
Another feature that is long overdue and helps when working on very large
projects is if you right click on a method declaration name or call you can
choose to see the View Call Hierarchy, which allows you to see when the method
is defined and all instances in the project where the method is called. Goodbye
find in project searches to determine all of the locations a method is
called.
Welcome to C# Optional and Named Parameters! If you done any VB development,
you have long used optional parameters and perhaps even named parameters. Now
they have been introduced in C#. They are structured a bit differently in C#,
but are easy enough to use. You simply add a default value to the parameter in
the method signature.
Optional Parameter Example -
// This Code:
public void ExampleMethod(int requiredInt){...}
public void ExampleMethod(int requiredInt, string optionalString)
{
//do something with optional string
ExampleMethod(requiredInt)
}
// Becomes:
public void ExampleMethod(int required, string optionalString=null){..}
I’m curious how many snobbish C# folks will switch from overloaded methods
though. I know these people they don’t play nice and were hated on the
playground.
Name Parameters go hand-in-hand with Optional Parameters in C# because you
need to use named parameters to call methods with Optional Parameters. You
cannot simply use the VB notation ExampleMethod(x, , y). Empty parameter clauses
will error out so you dothe following when calling a method with optional
parmeters. In your method signature all optional parms need to be defined last,
just as in VB.
// method signature
public void ExampleMethod(int required, string optionalString=null, string optionalString2){..}
ExampleMethod(requiredInt: 4,){...}
// only optionalparams need to be named
ExampleMethod(4, optionalString2: "test"){...}
// OR all param's named which is legal and more readable
ExampleMethod(requiredInt:4, optionalString2: "test"){...}
There are a couple new Data Types also in C#:
- BigInt, which is the equivalent to BigInt in JAVA, will be used for most
commonly for encryption keys.
- And dynamic…
Ah dynamic a regression of a data type that was not well received at my
presentation. Dynamic is like object, in that it can hold any data type, but
!!!! it can also be used to call any method or property on the object. Unlike
all other things in C# dynamic is well… dynamic … or non-statically typed. In
other words you do not need to know what type the object will hold, only how to
use it. You will not get a compile error if you attempt to use a method or
parmeter that is not available for the object, you will only get run-time errors
when attempting to use the object improperly. For example with dynamic all the
following is legal:
dynamic d1 = 7;
dynamic d2 = <span style="color: maroon">"a string"</span>;
dynamic d3 = System.DateTime.Today;
dynamic d4 = System.Diagnostics.Process.GetProcesses();
//casting back:
int i = d1;
string str = d2;
DateTime dt = d3;
System.Diagnostics.Process[] procs = d4;
Yes, it will be abused (so don’t hire hacks). Yes, it will remain because it
was created for Ruby, Python, and other dynamically typed languages. It will be
very handy for Office API calls and late-binding!!!
Multi-targeting will extend from .NET Framework 2.0 to .NET Framework 4.0
(including Client Profile). 4.0 Framework Client profile will not be a
web installation only and will now support 64-bit. It will also include new
classes such as EntityFramework run-time, Extensibility Framework, Dynamic
types, Parallel Programming (nope I haven’t mentioned that yet), and some
support for WCF.
Another one of my favorite demo’s is the code snippets. If you get a chance
find out more about these. I can see this improving development efforts and
increasing productivity for software shops with internal coding standards.
Ok. I’ll stop for now… But there is plenty more!!!