Coding standards a set of conventions and practices used in software, such as naming classes, variables, and files.

learn more… | top users | synonyms (1)

2
votes
2answers
97 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
148 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 ...
8
votes
4answers
473 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 ...
283
votes
9answers
67k 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
183 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
140 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
71 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
147 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 ...
4
votes
1answer
157 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
76 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
409 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 ...
542
votes
22answers
54k 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
154 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 ...
71
votes
20answers
12k 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
308 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
926 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 ...
26
votes
4answers
19k 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
120 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
123 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
5k 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?
15
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
1k 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
51 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
131 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
162 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
3k 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 ...
7
votes
2answers
733 views

How to Implement Error Handling [closed]

Even though I've programmed on a professional level for some years I still do not fully understand error handling. Although my applications work fine, the error handling isn't implemented at a ...
72
votes
14answers
19k views

Do I need to use an interface when only one class will ever implement it?

Isn't the whole point of an interface to for multiple classes to adhere to a set of rules and implementations?
0
votes
2answers
154 views

How to systematize tagging in code? [closed]

There are several almost standard tags used in comments: FIXME, TODO, BUGBUG. Which other tags do you use and for what? Are there any standards on using them, i.e. format (supplementing with date ...
13
votes
4answers
1k views

The problems with Avoiding Smurf Naming classes with namespaces

I pulled the term smurf naming from here (number 21). To save anyone not familiar the trouble, Smurf naming is the act of prefixing a bunch of related classes, variables, etc with a common prefix so ...
2
votes
2answers
75 views

Generic Repositories with DI & Data Intensive Controllers

Usually, I consider a large number of parameters as an alarm bell that there may be a design problem somewhere. I am using a Generic Repository for an ASP.NET application and have a Controller with a ...
2
votes
4answers
682 views

Coding convention regarding the usage of underscores [closed]

There seems to be divided opinion on this subject, and I wanted to get people's insights on whether they've found using underscore prefixes and suffixes to be helpful with coding or not. You know, ...
0
votes
2answers
75 views

Erlang return value conventions

Should functions that return tuples, always return tuples? For example, I have a function is_user_name_allowed that returns a tuple in this he form if the username is not allowed: {false, ["Reason ...
40
votes
6answers
20k views

Method vs Function vs Procedure

Simple question, but I often hear these three terms defined with such ferocity, but which have been known to me to mean different things over the years. What are the "correct" definitions of ...
1
vote
2answers
184 views

Is a try-catch-finally clause appropriate for production code?

While browsing around on SO, I came across an answer that suggested using a try-catch-finally clause to fix the problem he was having. (A rare bug that sometimes happened to his users). Someone ...
2
votes
1answer
310 views

Things developers do before the coding phase [closed]

I'm a new software developer, and in my internship my boss asked me to develop an application that allows him to manage his inventory. Something small but, for me, very enriching. The application is ...
6
votes
4answers
599 views

How do I introduce clean code?

My team has about 18 members and the code is generally good, using TDD and good specifications makes for working code. But I think they abuse comments in favor of writing cleaner, more readable code. ...
65
votes
17answers
11k views

Coding Guideline : Methods shouldn't contain more than 7 statements?

I was looking through the AvSol Coding Guidelines for C# and I agree with nearly everything but I'm really curious to see what other think of one specific rule. AV1500 Methods should not ...
11
votes
3answers
644 views

Bugs that can be avoided with coding standards [closed]

I am looking for statistics (or estimations) that backup the claim that coding standards help reduce bugs. Hard-numbers would be nice, although I haven't had much look finding any. I've even looked ...
2
votes
3answers
433 views

invoking methods within a conditional expression

In an oft-cited (if dated) reference for C# coding standards (pdf; from Lance Hunt), the statement is made, 33. Avoid invoking methods within a conditional expression. I've not seen this ...
15
votes
16answers
3k views

Coding standards and coding style, is it that much important? [closed]

There are a lot of ways of typing code, but I can't understand what is the good reason to adopt a certain standard or style if it does not change the way the code can be read and understood. Everyone ...
15
votes
12answers
2k views

Why use getters only as opposed to marking things final? [duplicate]

I'm working in a java role after working a couple years in functional programming. Our company was bought by google and I took a java role after the acquisition. Coming back to java as a polyglot ...
23
votes
10answers
2k views

Eliminating Magic Numbers: When is it time to say “No”?

We're all aware that magic numbers (hard-coded values) can wreak havoc in your program, especially when it's time to modify a section of code that has no comments, but where do you draw the line? ...
3
votes
3answers
456 views

Refactoring previous intern's noodle code with future interns in mind [duplicate]

Background I've run across this problem as I am currently an intern at a large company's local software division. I have been given the task of extending a project that several previous interns have ...
2
votes
4answers
449 views

When creating a library for a simple program, what must I do to protect others from its lack of thread safety?

When creating a library for a simple program, is it more cost effective to make it thread safe or is there a way to detect the program's use in a multithreaded program and ASSERT() or otherwise ...
7
votes
5answers
726 views

Where is this from (originally)?: “80% of the lifetime cost of a piece of software goes to maintenance”

In the Sun Java coding conventions document (here: http://www.oracle.com/technetwork/java/codeconv-138413.html), it states: "80% of the lifetime cost of a piece of software goes to maintenance" Does ...
10
votes
3answers
659 views

Questions for a peer code review

I am in the process of creating a short check-list for peer code reviews. So far I have come up with the following... Is there a unit test? Is there a integration test? Do you understand the code ...
6
votes
1answer
2k views

Database Application Design Best Practices [duplicate]

Once upon a time it was common practice for both the business logic and database logic to be written in the same language (eg PL/SQL, Transact SQL, etc), more recently the practice is to separate the ...
16
votes
14answers
4k views

How many mistakes does a good software developer make? [closed]

I am currently in a situation where a lot of people criticized me for making bugs (on my first local try - the first time I run the code for the first locally done test - , not on a committed repo ...