coding-standards

Writing standards for unit testing

I plan to introduce a set of standards for writing unit tests into my team. But what to include? These two posts (Unit test naming best practices and Best practices for file system dependencies in unit/integration tests) have given me some food for thought already. Other domains that should be covered in my standards should be how test...

MVC Namespace organisation

Hoping the SO community can help to resolve a debate in the office. At the moment our conclusion is 'it depends' ! In MVC, how do you organise your namespaces? Option A Do you go down the MS ASP.NET MVC route of having a Models, Controllers and Views namespace? Option B Or do you separate each MVC triad into it's logical 'functio...

SQL Formatting Standards

In my last job we worked on a very database heavy application and I developed some formatting standards so that we would all write SQL with a common layout. We also developed coding standards but these are more platform specific so I'll not go into them here. I'm interested to know what other people use for SQL formatting standards. Unl...

Is there a downloadable document available that encapsulates the core rules enforced by StyleCop?

Is there a downloadable document available that encapsulates the core rules enforced by StyleCop? We've settled on C#, and we're going to be using FxCop and StyleCop to enforce design and style guidelines. To help get folks ramped up to speed, we'd like to make sure they have printed versions of the reference materials on hand as casua...

What SQL coding standard do you follow?

Is there any widely used SQL coding standard out there? SQL is little bit different from C/C++ type of programming languages. Really don't know how to best format it for readability. ...

AddRef and function signature

I've always used the following rule for signatures of functions that return ref-counted objects based on whether they do an AddRef or not, but want to explain it to my colleagues too... So my question is, is the rule described below a widely followed rule? I'm looking for pointers to (for example) coding rules that advocate this style. ...

Document key ingredients of good software development?

I am writing an architecture and design document for software development at our company, that will contain the rules and guidelines for developers to follow. It is targeted at J2EE web applications, but I constantly keep mentioning the same basic 'ingredients' (for lack of a better word, and to avoid buzzwords) to introduce and defend c...

Why would var be a bad thing?

I've been chatting with my colleagues the other day and heard that their coding standard explicitly forbids them to use the var keyword in C#. They had no idea why it was so and I've always found implicit declaration to be incredibly useful when coding. I've never had any problems finding out what type the variable was (you only hover ov...

Should I Always Fully Qualify Column Names In SQL?

Out of interest when working with SQL statements should I always use the fully qualifed column name (tablename.columnname) even if only working with one table e.g. SELECT table.column1, table.column2 FROM table ...

Software Safety Standards

What industry known software safety standards has anyone had experience in having to adhere to while developing software that is involved in controlling a device/system that has potential to harm the individuals using it? ...

Coding standards and line length

Every coding standard I've ever seen has a recommended or absolute limit on number of characters in a line. There are various ways of working within this limitation, but I've not seen any specific guidance in this regard. Obviously, if possible, don't write excessively long lines. But what if that's not practical? How should long lines...

What anti patterns do you use even though you know you shouldn't?

Am I the only one that sometimes take the seemingly easy, but wrong, way out of certain design situations? I'll admit I've made my share of questionable Singleton objects. Besides that, I've been known to make a God object or two to make things seem easier. Do you ever use an anti-pattern even though you know you shouldn't? ...

Is it good practice to create once-used variables?

A colleague of mine refactored this code: private void btnGeneral_Click(object sender, RoutedEventArgs e) { Button button = (Button)e.OriginalSource; Type type = this.GetType(); Assembly assembly = type.Assembly; string userControlFullName = String.Format("{0}.{1}", type.Namespace, button.Name); UserControl userContr...

Coding Standards

For those of us that have programmed enough I’m sure we have come across many different flavours of coding standards that you can use when it comes to programming. e.g. http://msdn.microsoft.com/en-us/library/ms229042.aspx You might derive your coding standards for the current company you work for or from the original author of the cod...

What are the url parameters naming convention or standards to follow

Are there any naming conventions or standards for Url parameters to be followed. I generally use camel casing like userId or itemNumber. As i am about to start of a new project, i was searching whether there is anything for this, and could not find anything. I am not looking at this from a perspective of language or framework but more as...

Can Method names start with Get in .NET

I came across a recent Audit report in our company for the code we maintain which says that we should not use Get in the method (not properties) naming like in GetSearchResults or GetXyzInformation. I looked up the MS guidelines (http://msdn.microsoft.com/en-us/library/4df752aw(VS.71).aspx) for method naming and as per that Get is allow...

.NET Coding standards and framework for a web service

I have been given to the task of writing a coding standards document and creating a framework for web services. I've looked at numerous articles but I am still stumped to what is exactly required especially when developing a framework as it is completely different from application code. Has anyone got any useful tips or books they can...

Should you use pointers (unsafe code) in C#?

Should you use pointers in your C# code? What are the benefits? Is it recommend by The Man (Microsoft)? ...

Lance Hunt's C# Coding Standards - enum confusion

My team has recently started using Lance Hunt's C# Coding Standards document as a starting point for consolidating our coding standards. There is one item that we just don't understand the point of, can anyone here shed any light on it? The item is number 77: Always validate an enumeration variable or parameter value before con...

Coding guides: How do you split up your large source files?

The project I'm working on has just hit 4200 lines in the main C# file, which is causing Intellisense to take a few seconds (sometimes up to 6 or so) to respond, during which Visual Studio locks up. I'm wondering how everyone else splits their files and whether there's a consensus. I tried to look for some guides and found Google's C++...