Question

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

Was it helpful?

Solution

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

OTHER TIPS

Framework Design Guidelines is the only thing i found

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.

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

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top