coding-standards

In C++, is it still bad practice to return a vector from a function?

Short version: It's common to return large objects—such as vectors/arrays—in many programming languages. Is this style now acceptable in C++0x if the class has a move constructor, or do C++ programmers consider it weird/ugly/abomination? Long version: In C++0x is this still considered bad form? std::vector<std::string> BuildLargeVector...

"this" for member variable? why not "m_" or just "_" like old times?

Recently I've taken note of class member variables in C# moving to the this.foobarbaz for every reference for class member variables rather than the previously acceptable m_ or just _. How many of you seasoned programmers are coding to this new acceptable standard, if so why, if not why? I ask because it changes our coding standards at w...

Tool to enforce Delphi coding standards

I need an analysis tool that will help to enforce coding standards for our Delphi codebase. A few colleagues have suggested the following tools: Code healer Pascal analyzer I've had a look at these tools and they aren't suitable. I was hoping to find a tool for Delphi that is similar to CheckStyle for Java or StyleCop for C#. Any ...

Correction depends on Java Coding Standard

I use CheckStyle Plug-in for make my codes fit Java Coding Standard.The programme has lacking ability as the programme doesn't correct the errors on-time.I want to a programme which make my code correct on-time.Suppose that,I'm writing code then the plug-in warns me this line of code doesn't suitable for Java Coding Standard.In CheckStyl...

To use or not to use C++0x features

Possible Duplicate: How are you using C++0x today? I'm working with a team on a fairly new system. We're talking about migrating to MSVC 2010 and we've already migrated to GCC 4.5. These are the only compilers we're using and we have no plans to port our code to different compilers any time soon. I suggested that after we do ...

Are protected members/fields really that bad?

Now if you read the naming conventions in the MSDN for C# you will notice that it states that properties are always preferred over public and protected fields. I have even been told by some people that you should never use public or protected fields. Now I will agree I have yet to find a reason in which I need to have a public field bu...

StyleCop equivalent for SQL Server?

Is there any tools like StyleCop for SQL Server? We need the same features of StyleCop (enforce a set of style and consistency rules). [Additional Feature]: Integration with SQLServer Management Studio would be cool. ...

How to Be Python 3 Ready?

What are the current rules for writing python code that will pass cleanly through 2to3 and what are the practices that seem to be best suited to writing code that will not become mired forever in version 2. I have read from the SciPy/NumPy forums that "100% test coverage" (unit testing) is important for many people, and I am not sure if...

CSS and filename coding conventions

Hi, What kind of convention do you (or your company) run on filenames and CSS class names? For example, let's say you have these class names: window, window top, window top left, window top right. How do you name those class names (and such filenames)? Currently I am doing the following: .window { background: url(images/window.png); ...

JavaScript braces on new line or not?

Hi, At work, we place braces on the next line, but at home, I do the opposite. Which one do you prefer? (K&R vs OTBS) function something() { // ... } function something() { // ... } A lot of JavaScript libraries seem to use the OTBS (one true brace style). I'd like to follow them for consistence among other JavaScript projec...

How do you write quality code under duress?

Possible Duplicate: How do you manage to write high quality code very quickly? When emergency code fixes are required ASAP, how do you ensure that the code you're writing is better than the code you replaced? What processes do you keep when time is of the essence? ...

Global Variables or Tricky variable Passing Scheme?

Hey everyone, As a bit of a background I'm about to be a senior in Comp E and currently working on a project for my internship involving iPad development using Monotouch and C#. As a student with multiple projects at once during the semesters, code style is often completely ignored in order to get the final product working. I'm sure you...

Should you always use 'int' for numbers in C, even if they are non-negative?

I always use unsigned int for values that should never be negative. But today I noticed this situation in my code: void CreateRequestHeader( unsigned bitsAvailable, unsigned mandatoryDataSize, unsigned optionalDataSize ) { If ( bitsAvailable – mandatoryDataSize >= optionalDataSize ) { // Optional data fits, so add it to...

Supporting Code Metrics with Case Studies

I'm principally interested in case studies on code metrics, relating code readability to defect reduction, that justify taking seriously cyclomatic complexity or some similar metric. Wikipedia has this example: A number of studies have investigated cyclomatic complexity's correlation to the number of defects contained in a mod...

What's the reason why table layout in code is considered bad?

My colleagues tell me that table based formatting of code is bad and it is no readable and I should follow conventions. What's that bad about table based formatting? Why is it banned? I'm asking because for me it's much more readable. Examples (not real code): if (res == ResultType.Failure) something = ProcessFailure(...

Multiple returns versus Exit for

I have the following VB.NET code (but for each loops are in most languages, thus the language-agnostic tag): Public Function VerifyServiceName(ByRef sMachineName As String, ByRef sServiceName As String) As Boolean Dim asServices As System.ServiceProcess.ServiceController() = System.ServiceProcess.ServiceController.GetServices(sMa...

javascript ? : notation

This is probably a dumb question, but... I found this snippet of code in my travels in researching JSON: var array = typeof objArray != 'object' ? JSON.parse(objArray) : objArray; I'm seeing more and more of the ? and : notation. I don't even know what it is called to look it up! Can anyone point me to a good resource for this? (btw...

coding style: use if/elif/else if each branch returns?

Which coding style do you prefer, and why? if case1: return res1 if case2: return res2 return res3 or: if case1: return res1 elif case2: return res2 else: return res3 or: res = None if case1: res = res1 elif case2: res = res2 else: res = res3 return res Reason: I have code that looks like this, an...

PHP codesniffer (phpcs) - how to allow override when using as part of a svn pre-commit hook?

We have a PHP 5 web application and we're currently evaluating PHP CodeSniffer in order to decide whether forcing code standards improves code quality. We use subversion for our code repository and deployment base and I have added a SVN pre-commit hook to ensure all files committed are free from coding standard smells. The hook technica...

Best way to track challenges/goals completed by a member?

This is to be an application-agnostic question, but one I'd like to get a better answer on. What is the best set-up to track users completing a challenge or goal? Think similar to Stack Overflow, where if you hit a certain target you're awarded a badge. Currently, I'm the developer of a website and attached Facebook application. I want...