Share via


Language design for Refactoring

A question came up on the Yahoo! Groups Refactoring Group about what language design would be best to support Refactoring.

We think about this quite a bit, but usually we phrase the question more generally:

What language design would make it easiest to write tools that work well?

That includes Refactoring, as well as Intellisense, Syntax Coloring, etc.

The answer seems to be that explicitness: a language that forces the developer to be explicit, instead of implicitly inferring stuff from the context.

It seems like this is really the answer to:

          What language design makes the code easy to read?

Unfortunately, language readability is often at odds with writability. This is a point that language designers struggle with all the time.

In C# 2.0, there are two points of inference that were added to the language:

  1. Generic method type parameters are inferred from the concrete parameters.

  2. Anonymous method type is inferred from the usage

We discussed, but did not add inference of the type of the instance variable in a ‘foreach’ statement.

There’s an MSDN Magazine article that discusses some of these points in C# 2.0.

 

In general, the design of C# has focused on making your code more explicit that C++, to avoid many of the pitfalls we observed in C++. That same explicitness has made C# Refactoring easier to get right.

Comments