Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How has your coding standards document changed when you upgraded to C# 3.0 / VS2008?

We are in the process of upgrading our projects from C# 2.0 / VS2005 to C# 3.0 / VS2008. As part of the upgrade, we are adding some items to our coding standards document.

How would (or did) you change your coding standards document when upgrading from C# 2.0 / VS2005 to C# 3.0 / VS2008?

like image 659
Sir Rippov the Maple Avatar asked Dec 22 '22 13:12

Sir Rippov the Maple


1 Answers

You could/should give advice about:

  • When to use query expressions vs dot notation
  • Any restrictions on the use of lambda expressions (e.g. "don't modify captured variables). (This could also apply to anonymous methods in C# 2 of course.)
  • When to write extension methods
  • When to use implicitly typed variables (var)

The last two of these cause some controversy, particularly var.

If your conventions give any design guidelines, I'd suggest that you also advise programmers to consider using delegates for specialisation where previously they might have used inheritance or interfaces. A good example of this is sorting - it's easier (and more readable) to use a projection to specify a sort order than to write an implementation of IComparer<T>.

like image 53
Jon Skeet Avatar answered Dec 25 '22 02:12

Jon Skeet