views:

405

answers:

2

I am currently writing an open source wrapper for a COM object. I have just installed StyleCop and run it against some of my code, and as I expected it threw up a load of warnings (some of which I should have been doing already eg adding "this." to all local method calls and variables)

How many of these warnings should I try and reduce? Which ones would be the best ones when writing an open source library?

A: 

Most large open source projects have their own style guidelines. For example, here's the Apache C Language Style Guide.

As a start, I suggest trawling the FAQ for the OS project you're interested in and take it from there.

Anyway, I'm sure there'll be plenty of people who'll quickly let you know if you're breaking any existing style rules in a big way! ;-)

Take heed of all the warnings, usually they are trying to tell you something useful. Don't finish up "programming by coincidence" (book excerpt) as the Pragmatic Programmers say!

Edit: I didn't realise that this was your own, new, OS project. My bad. Anyway, I'd have a sniff around some similar already existing OS projects and see if they have any style guides. Definitely, check out Steve McConnell's book Code Complete (Amazon link - sanitised for the script kiddie link nazis that roam these halls).

What I said about warnings and "programming by coincidence" still applies! (-:

HTH.

cheers,

Rob

Rob Wells
It's my own open source project so there are no FAQ or styles in place....yet.
Nathan W
@Nathan - ah. edit added.
Rob Wells
+5  A: 

The general idea with StyleCop is: All of them :)

The more options you turn off the less value StyleCop has in enforcing a one-true code format. That being said, if you don't like some of the options then some options is better than none, include the StyleCop settings file with your code and others working on it can then use the same settings.

Some of the settings may seem weird at first if you're not familiar with StyleCop, but having used it for two years now I leave all the options on and our team is quite happy with the results.

I'd also say that if you're providing a library or framework that using FxCop may be more important than using StyleCop.

Simon Steele
Good call on FxCop. Together they make a great team!
DeletedAccount