coding-standards

Dealing with some grey code style issues

We have an intermediate developer who is really good at what he does, but there is one rough edge to this diamond. He's really insistent that every method have only one entry and one exit point. The approach that I'm taking is to not make too big a deal out of it for code that he writes (except when there is a serious clarity issue). Wh...

Is there any NSIS Best Practices or Coding Standards around?

I'm creating several NSIS installers and as my expertise in this thing grows up I'm no longer happy with just making things work, I would like to see if there are some best practices or coding standards around this language, like how to write conditionals, variable names, unistallers, etc.. ...

Your least favorite C++ Coding guideline

Hi, As a counterpart to C++ Coding Guideline 102, which of the 101 guidelines of Sutter & Alexandrescu do you violate or ignore most often, and why? ...

How to find out about the accepted coding styles

Where to read up on (the best-practice in) source code formatting, for individual languages i.e. what are the conventions for naming variables etc., for indentation and where to place braces, how and where to include comments, etc. For example for C Kernighan and Ritchie's book The C Programming Language and Linus Torvalds' Linux kerne...

Most crucial elements in a light-weight C++ coding standard

I've been involved in developing coding standards which were quite elaborate. My own experience is that it was hard to enforce if you don't have proper processes to maintain it and strategies to uphold it. Now I'm working in, and leading, an environment even less probable to have processes and follow-up strategies in quite a while. Stil...

PHP Constants: Advantages/Disadvantages

Lately I've been in the habit of assigning integer values to constants and simply using the constant name as a means of identifying its purpose. However, in some cases this has resulted in the need to write a function like typeToString($const) when a string representation is needed. Obviously this is inefficient and unneccesary, but is o...

Whats the reasoning behind the different brace forms?

I'm reading through the Zend Framework coding standards, where they state that curly brace after a Class definitions should be on the next line, the "one true brace form". class MyClass { function.... } I usually have the braces on the same line: class OtherClass { function ... } What's the reason for putting the brace on t...

How to avoid duplicating logic on two similar WinForms?

I have two forms, form A and form B. These forms must differ in appearance, but they share a lot of logic. The problem is that this logic is tied to the appearance (validation on button click, events being fired, etc.). For example, I have a name field, and when the save button is pressed, I need to fire an event which causes the pare...

What Delphi coding standards document(s) do you follow?

What Delphi coding standards document(s) do you follow? Our company is looking at putting some better coding standards in place, to improve our code’s readability, reviewability, and maintainability. We’ve come across CodeGear’s “Object Pascal Style Guide”, but it hasn’t been touched in quite a while and I imagine a number of people ha...

What should be included in a C# Programming Standard?

I've been tasked to write our department's C# Programming Standard (including guidelines). What sort of standards/guidelines should I include? I've already taken bits from various standards around the net (and pieces from Code Complete), but I'd like hear from developers in the field. I've already got: Naming Conventions - General/Var...

definition of filename ?

After years of programming it's still some of the simple things that keep tripping me up. Is there a commonly agreed definition of filename ? Even the wikipedia article confuses the two interpretations. It starts by defining it as 'a special kind of string used to uniquely identify a file stored on the file system of a computer'. Tha...

MySQL And C applications

When building a application that accesses a MySQL database on linux using C/C++ i have to dynamically link into the mysql client library. Is there a way in which i can statically link the application so that the mysql client libraries are no longer required? What is the best practice, with regards to C\C++ development, to include rathe...

What metrics should we use to judge code quality?

I'm currently working on a large project, where many developers worked over time and the code was terrible. After many refactorings we now arrived a point, where the code is ok. Now I'm thinking what "ok" means - probably for everyone something different. Do you think it's possible to specify "ok"? What is important? NDepend metrics? Te...

PHP coding standards

I've been looking for some guidelines on how to layout PHP code. I've found some good references, such as the following: http://www.dagbladet.no/development/phpcodingstandard/ and this question on SO. However, none of that quite gets to what I'm specifically wondering about, which is the integration of HTML and PHP. For example: is ...

CSS Conventions / Code Layout Models

Has there been any attempt and creating a formalized method for organizing CSS code? Before I go and make up my own strategy for keeping things readable, I'm wondering what else is out there. Goggle hasn't been very helpful, as I'm not entirely sure what terms to search for. I'm thinking more along the lines of indenting/spacing, when ...

How to consistently organize code for debugging ?

When working in a big project that requires debugging (like every project) you realize how much people love "printf" before the IDE's built-in debugger. By this I mean Sometimes you need to render variable values to screen (specially for interactive debugging). Sometimes to log them in a file Sometimes you have to change the visibility...

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? ...

Implementing and Enforcing Coding Standards

My team (of which I am the newest and most junior member) has increased in size from 3 to 9 developers in just about 1 year. Our primary product has increased in complexity and we are about to undertake a year long port/re-write to Silverlight. In the past there has been no specific style/standard enforced. I suggested to my boss that...

What should coding guidelines do, and are there any good examples of guidelines?

What are some good examples of coding guidelines. I'm not really looking for anything specific to a single language. But what should I be doing/evaluating as I write coding guidelines? Such as how flexible should the guidelines and how much should decisions be left to the programmer or to someone else or even pre-decided by the guidelin...

What "bad practice" do you do, and why?

Well, "good practice" and "bad practice" are tossed around a lot these days - "Disable assertions in release builds", "Don't disable assertions in release builds", "Don't use goto.", we've got all sorts of guidelines above and beyond simply making your program work. So I ask of you, what coding practices do you violate all the time, and ...