Coding standards, or coding conventions, are sets of rules or guidelines designed to govern the process of code production in a software project. They're usually based on industry best practices or generally accepted conventions. They include naming conventions, style, prohibited features, and more.

learn more… | top users | synonyms (1)

0
votes
0answers
44 views

what are the most important coding standards in c# [on hold]

I am a college student creating a C# program for the 3rd year project. In my project coding standard is a main concern. But I do not have a better understanding about C# coding standards to follow ...
-4
votes
1answer
58 views

Should I use spaces around if else control structure and curly braces? [on hold]

Should I use spaces around if else control structure and curly braces? What do you think? if ($a === $b) { foo(); } else { $bar(); } or if($a === $b){ foo(); }else{ bar(); } I ...
0
votes
3answers
59 views

Handling source code table alignment

Sometimes there is need to have tables (big or small) in source code. ItemType const SomeTable[] = { // id name min max ITEM( 3, "Foo", 70, 180), ITEM(13, "Bar", 30, 50), ...
1
vote
6answers
200 views

What to use instead of IDs in selectors in CSS

I recently installed a csslint package for my Atom text editor. I keep getting warnings saying "Don't use IDs in selectors." I found this weird since I've always been using IDs in selectors in CSS, ...
1
vote
0answers
40 views

Objective-c anonymous property coding style

If I have an interface defined like @interface MyClass @property (nonatomic, copy, readonly) NSString *myString; @end so that myString is externally visible but can't be written, what would be ...
1
vote
4answers
2k views

Usage of magic strings/numbers [closed]

This is somewhat controversial topic, and I guess there is as many opinions as there are programmers. But for the sake of it, I want to know what are the common practices in business (or in your work ...
3
votes
3answers
339 views

No exceptions C++ and partially constructed objects

Looking over Joint Strike Fighter Air Vehicle C++ Coding Standard, rule AV 73 states something on the lines: Default c++ constructors should be avoided if that means leaving object in a partially ...
0
votes
2answers
34 views

SQL - for some attributes specific to different clients' users, how to handle schema?

I have clients, each of whom have an app with a bunch of users. Their user data could be pretty different, but there is also a lot of overlap. Ex: all their users have "gender" and "age" and plenty ...
1
vote
3answers
139 views

Are project naming conventions more important than language naming conventions? [closed]

I'm working on a project with a senior developer and he doesn't really abide by the naming conventions of the language that we're using. The project is in Go and he uses underscores for everything. ...
0
votes
7answers
201 views

In ifs inside for loops, prefer checking for true, or for false and continue?

I'm discussing this with a work colleague. Say we want to sum the numbers from 0 to 9 skipping 5. He prefers this: int sum = 0; for(int i = 0; i < 10; ++i) { if(i == 5) { continue; ...
2
votes
1answer
207 views

Reducing the complexity of over-designed code

I have just started working at a company where I have inherited a C# codebase from a previous developer. I know programming well, have an engineering degree + an (unfinished, several year long) PhD ...
0
votes
0answers
70 views

Is there any necessity to pass a variable parameter to a method while the variable declared global? [duplicate]

I am writing a class in java of Monte-Carlo algorithm. Here is the written code - public class MonteCarlo { int[][] matrix; public void monteCarlo(List<Node> nodeList) { matrix ...
2
votes
2answers
99 views

Typedefs to convey relations between classes

I'm wondering if the following use of typedefs is any good practice, or if there are any downsides to it. Basically I have alot of "data"-structs, which are intended to be used in (globally unique) ...
0
votes
2answers
69 views

Why should a HashMap be used(in functions) to determine which value to return(for a key) when an if else construct can do the job in better time?

While I was recently working at a big company, I noticed that the programmers there followed this coding style: Suppose I have a function that returns 12 if the input is A, 21 if the input is B, and ...
1
vote
2answers
238 views

How should I compare two database tables - with SQL or using Java? [closed]

I have two tables with different structure. I should compare ID from 1st table with ID of the intermediate table and then comapre TXT field of the intermediate table with TXT field of the 2nd table. ...
13
votes
2answers
996 views

Are there well-known PowerShell coding conventions?

Are there any well-defined conventions when programming in PowerShell? For example, in scripts which are to be maintained long-term, do we need to: Use the real cmdlet name or alias? Specify the ...
1
vote
2answers
77 views

Helping to avoid first time implementation mistakes [closed]

I am getting close to "finishing" my first major, non-trivial PHP/MySQL website project, and while the code is generally fine and works properly, there are many problems with it considering the fact I ...
0
votes
1answer
92 views

Where does the Liskov Substitution Principle generally lie in different constructor parameter lists?

There are two other questions I've posted that dealt with specific cases of this: Where does the Liskov Substitution Principle lie in a subclass passing extra arguments to similar, tightly-related ...
3
votes
4answers
432 views

Are `switch` statements generally used wrong? [closed]

I see most developers using switch statements with breaks in each and every case. Is this usage of switch statements inappropriate since a simple set of if-else statements would suffice? Is it OK for ...
13
votes
6answers
10k views

Naming classes, methods, functions and variables [duplicate]

There are 3 important naming conventions: with_underscores PascalCased camelCased Other variants are not important because they are not commonly used. For variables it seems that the one with ...
12
votes
5answers
778 views

Evolution in coding standards, how do you deal with them?

How do you deal with evolution in the coding standards / style guide in a project for the existing code base? Let's say someone on your team discovered a better way of object instantiation in the ...
0
votes
2answers
47 views

Capitalizing custom methods in a SDK based project [closed]

In projects which need heavy SDK usage, like Android and iOS development, I want the methods/functions I write to be obvious and since the whole framework is written with lower case method names I ...
2
votes
2answers
328 views

Should we refactor our existing codebase to use functional programming, especially streams? [closed]

We have a large project written in PHP. It almost exclusively uses imperative operations, as in example 1. Should we refactor our existing code to use functional operations? Do you think that the code ...
2
votes
2answers
128 views

Is embedding data in a executable considered a good practice?

Embedding data (such as images) in a executable seems to have a few advantages, like easier distribution of the executable and easier compatibility with different OSes. But, is it a good practice? ...
1
vote
3answers
169 views

Coding convention question about AS3 duplicate variable definition

AS3's got some awkward rules about variable scope, due to its use of hoisting. I don't like pointlessly leaving a bunch of compiler warnings lying around, but it's more important to me for my code to ...
9
votes
4answers
527 views

Are there any actual drawbacks to self-referential method chaining?

I recently suggested a method of chaining be implemented for a certain class in a certain project so readability of the code could be improved. I got a "fluent interfaces should not be implemented ...
306
votes
9answers
76k views

Why is 80 characters the 'standard' limit for code width?

Why is 80 characters the "standard" limit for code width? Why 80 and not 79, 81 or 100? What is the origin of this particular value?
3
votes
3answers
195 views

Easy way to make old javascript files conform to new quoting standard?

We've just started putting linting in place at my workplace, and a lot of the devs didn't realize our standards called for double-quotes everywhere. About 50% of the codebase uses single-quotes, so ...
0
votes
1answer
149 views

What do you call classes that do arbitrary work in your project? [closed]

I work on a lot of projects with different teams. Every project has its own conventions, including what to call arbitrary classes that don't lend themselves to obvious names. As a counter-example, ...
17
votes
15answers
2k views

I hate one of our coding standards and it drives me insane, how to process it? [closed]

Disclaimer: Not as exaggerated as the title suggests, but it still makes me uncomfortable. I'm just going to express honestly, so take it with a grain of salt. Just pretend that I'm talking about that ...
0
votes
1answer
86 views

What are the key areas to evaluate software (codebase) on? [closed]

I have been asked to do a code review of about 50 applications over a period of 6 weeks. (Management has changed and the new CTO asked for an full internal software audit) I am wondering, what are ...
3
votes
2answers
160 views

Are there any widely accepted sets of standards/practices for secure coding? [closed]

The title should be fairly self-explanatory. We need to update our coding standards, and as part of this process we've been asked to try and follow an industry standard from a ...
5
votes
1answer
211 views

Why is the use of JavaScript in HREF attributes discouraged?

Disclaimer: I came to Programmers.SE to ask this question because I understand this is the place to ask this type of question, and not necessarily stackoverflow. If I am wrong, please close the ...
0
votes
0answers
78 views

Improving the speed of coding in Fortran [duplicate]

I've got about 1.5 years of experience in writing Fortran 2003 codes for scientific applications (duh), and I'm finding myself now in the situation in which I need to write working code as fast as ...
2
votes
3answers
423 views

Should one value simpler code over performance when returning multiple values?

I'm too often facing situations where I need to get several types of information from a method. I usually think long and hard to circumvent these situations but I'm thinking it's pointless work that ...
563
votes
22answers
63k views

Where did the notion of “one return only” come from?

I often talk to Java programmers who say "Don't put multiple return statements in the same method." When I ask them to tell me the reasons why, all I get is "The coding standard says so." or "It's ...
0
votes
2answers
205 views

C Linked List Implementation Pointer vs. Pointer-to-Pointer Consistency

To get some practice in C, I'm writing some basic functions for operating on a linked list of ints. I started out with functions that accepted as a "list" a pointer to the head node. Now, I find ...
72
votes
20answers
13k views

How important is it to reduce the number of lines in code?

I am a Software developer who works on J2SE (core java). Often during our code reviews we are asked to reduce the number of lines in our code. It's not about removing redundant code, it's about ...
0
votes
1answer
896 views

Project directory structure

Actually i'm using this project directory structure http://framework.zend.com/manual/1.12/en/project-structure.project.html But recently i started using namespaces in all my php-classes like: ...
8
votes
11answers
937 views

When, if ever, can code standards be ignored? [closed]

My company has decided to use stored procedures for everything dealing with the database (because they didn't know of any other way besides raw SQL), and as the saying goes "When in Rome..." so I try ...
27
votes
4answers
22k views

Why is #include <iostream.h> bad?

I was reading another thread where a guy asked about C++ books for beginners, and one of the programmers answering wrote this: Some warnings: avoid all books that present an "hello world" stating ...
0
votes
1answer
125 views

Method Parameters Ordering [closed]

I was recently changing a method to add in an additional parameter, and I couldn't help but wonder if there were "best practices" or "generally accepted rules" in deciding what order parameters of a ...
0
votes
1answer
134 views

Is there a particular coding standard with comments between function name and body?

I'm integrating with a shipping API built in php. They have a strange coding standard where the comments are between the function name and the first curly bracket.. which - subjectively - makes the ...
11
votes
13answers
6k views

Should I add an “Abstract” prefix to my abstract classes? [closed]

Suppose I have an abstract class named Task. Is there a standard or convention that would suggest I should name it AbstractTask instead?
16
votes
16answers
1k views

Do else blocks increase code complexity? [closed]

Here is a very simplified example. This isn't necessarily a language-specific question, and I ask that you ignore the many other ways the function can be written, and changes that can be made to it.. ...
16
votes
5answers
2k views

What does it mean when some technology is a “standard”?

I started learning Java EE 7 and I am frequently coming across this term "standard", and I don't understand what it means. So, for example, here is a quotation from this book: Contrary to SOAP ...
0
votes
1answer
57 views

How to format Android view IDs

I struggle with this every time I work on a project. I am not entirely sure what the standard conventions are for creating view ids. I usually use something like view_more_button but then if we ...
0
votes
2answers
134 views

At what point should you start putting functions in a new file? [closed]

I'm currently writing a python script. It's currently about 400 lines long, and it seems like it's getting a bit long, as when I'm trying to scroll through it with eclipse it takes a bit to get from ...
0
votes
1answer
164 views

Should I continue stressing development standards? [closed]

I've been with my software team for about three years now, and just recently I brought up the concept of variable naming conventions (across all languages, but C#/VB.Net specifically). We really ...
0
votes
9answers
4k views

Line break before/after operator [closed]

While Sun's Java code convention suggests to put line break before the operator many other guidelines disagree with it. I do not see any obvious pros and cons, so are there advantages of using one of ...