views:

486

answers:

5

I am looking for something like idiomatic ruby for c# programmers

It should:

  • be for people that can already programm

  • be terse

  • not be to basic

just found a better thread for this question on stackoverflow: c-coding-standard-best-practices

A: 

Framework Design Guidelines is the only thing i found

LDomagala
A: 

This is not a bad comparison between C# and Java, which hits most of the C# idioms, but beware that there are two different idioms at work here: C# idioms and .NET idioms. For example, in C#, it is perfectly acceptable to use underscore in identifiers, but not do in VB.NET, therefore while it is not mandated so, it is best practice to never use underscore in public identifiers so that VB.NET can access them.

plinth
Unfortunately it seems to be stuck at C# 2 - there are various idioms which arrived with C# 3.
Jon Skeet
You can't have everything. Where would you put it?
plinth
While it may be technically possible, it isn't considered acceptable style to use underscores in C# identifiers.
Greg Beech
+6  A: 

You might want to try Effective C# and More Effective C#, both by Bill Wagner.

I haven't read either of them properly (must get round to doing so some time) but I've heard good things.

Assuming you're using C# 3, I would try to make sure you're familiar with:

  • Generics and what type inference on generic methods can do with you
  • IEnumerable<T> and iterator blocks
  • LINQ in general, and LINQ to Objects in particular (other LINQ flavours are useful in some places - LINQ to Objects is useful almost everywhere)
  • Delegates, particularly lambda expressions and anonymous methods
  • Object and collection initializers
  • Extension methods - be aware of them, and consider them for utility methods. In particular they're handy if you want to add your own LINQ operators
Jon Skeet
I have those two on my desk and will start on them when I finish your book, Jon :)
Gorpik
you shouldnt be to modest to mention your own book. i´m reading it right now and it helps alot:)
LDomagala
A: 

there is a program from MSDN that checks your programs for "best practices": FXCop

and here is a guide in the MSDN that tells you about convetions and idioms: MSDN

oh finally here is another guide on the MSDN: MSDN

LDomagala
A: 

If you want to ensure the style of your code is as per Microsoft's recommendations, take a look at StyleCop. Yes, it is very picky, and I don't agree entirely with all the rules, but in the general case it does make for more readable code, which is more consistent between developers.

Greg Beech