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

learn more… | top users | synonyms (1)

17
votes
3answers
1k views

Why does the Lisp community prefer to accumulate all the parentheses at the end of the function?

Why does the Lisp community prefer to accumulate all the parentheses at the end of the function: (defn defer-expensive [cheap expensive] (if-let [good-enough (force cheap)] good-enough ...
5
votes
2answers
336 views

Should functions always return a success/failure status? [duplicate]

Possible Duplicate: When and why you should use void (instead of i.e. bool/int) What is the reasoning behind making all functions (and methods!) return a uniform type, usually int, as a ...
32
votes
7answers
7k views

Excessive use “final” keyword in Java [duplicate]

While I understand what the final keyword is used for in the context of classes and methods as well as the intent of its use for in regards to variables; however, the project I just started working on ...
3
votes
2answers
892 views

Setting $_POST variables as a means of passing data / Not passing parameters in functions

I've got a legacy PHP web application wherein almost each and every function makes references to $_POST variables - retrieving their values, AND setting them (or setting new POST variables) as a means ...
1
vote
3answers
605 views

Importance of algorithms in a telephonic interview

I had taken a telephonic interview and the interviewer has given some problem for which I was supposed to give him the algorithm. Since its was a telephonic interview and I had no paper or pen, so I ...
2
votes
4answers
2k views

Directory structure of web application written in PHP [closed]

I would like to know which convention (if any) you use for your PHP web application projects.
4
votes
2answers
464 views

Why are people afraid to die()?

I have seen a lot of people (first comment) hating die(); instead of exit; As the follow-up comments on that post note, die and exit are the same - the attitude appears to be one of perception, with ...
36
votes
12answers
2k views

Handling Coding Standards at Work (I'm not the boss)

I work on a small team, around 10 devs. We have no coding standards at all. There are certain things that have become the norm but some ways of doing things are completely disparate. My big one is ...
2
votes
6answers
2k views

Line break before/after operator

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 ...
18
votes
9answers
683 views

Advantages and Disadvantages of Forced Code Reformat

I'm currently working at a place that may be looking at forcing developers to use an automated code formatter on version control check-in. I'm looking for developers opinions on the advantages and ...
54
votes
17answers
3k views

Are first person comments distracting and unprofessional?

I just found myself writing the following comment in some (archaic Visual Basic 6.0) code I was writing: If WindowState <> 1 Then 'The form's not minimized, so we can resize it safely ...
12
votes
10answers
690 views

Is it OK to reformat another developers code while modifying/adding to a module?

While developing in a group atmosphere and adding or modifying features in some code base. Is it considered offensive or impolite to reformat the previous developers code to bring it up to current ...
65
votes
13answers
11k views

Why do most of us use 'i' as a loop counter variable?

Has anyone thought about why so many of us repeat this same pattern using the same variable names? for (int i = 0; i < foo; i++) { // ... } It seems most code I've ever looked at uses i, j, ...
5
votes
13answers
705 views

Logging, do you do it?

Back on my theme of late: interview questions. Was recently asked to describe a time I'd used logging. My first instinct was to respond with compiler warnings set to full and error-out. What he was ...
16
votes
14answers
2k views

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

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 ...
63
votes
12answers
3k views

Is there a point to including a “change log” in every code file when you are using version control?

I was under the impression that a version control system eliminated the need to have "change logs" plastered everywhere in the code. I've often seen the continued use of change logs, including big ...
6
votes
3answers
424 views

Converting a 1,000,000 rows database

If I have a database that stores the login credentials of 1,000,000 users in PLAINTEXT, how much effort will it take me to md5 hash these passwords?
14
votes
10answers
1k views

How important is a good coding style for the decision to hire a programmer?

Even as a student I am asked to review the code of programmers who have (not) passed a test (create a list of Fibonacci numbers on android). While I am very strict on coding style I just read about ...
4
votes
1answer
288 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 ...
3
votes
4answers
474 views

Hungarian Notations/Systems Hungarian Should I? [closed]

I was wondering would it be worth using a form of standard such as Hungarian Notation/Systems Hungarian? Why would I bother if everything I'm doing now is working fine?
12
votes
8answers
656 views

Are naming convention guidelines worth caring about?

I name my variables using the .Net conventions: camelCase for variables and fields (I tend to use _camelCase for private fields in a class) PascalCase for methods, properties and classes The only ...
7
votes
2answers
470 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 ...
5
votes
4answers
430 views

How to apply one of the OOP concepts (Closed for Modification and Open for extension)?

Days before, I created Question, Quiz, and Main classes. One Quiz has one or more Questions. From the main class I first create Question objects (the constructor accepts an array of numbers). The Quiz ...
23
votes
3answers
3k views

if ('constant' == $variable) vs. if ($variable == 'constant')

Lately, I've been working a lot in PHP and specifically within the WordPress framework. I'm noticing a lot of code in the form of: if ( 1 == $options['postlink'] ) Where I would have expected to ...
0
votes
2answers
1k views

[C] Address of array elements

What is the most readable way of using address of an array element? I usually see &array[n] but I personally think array+n looks cleaner and more readable. What do other C coders prefer?
54
votes
20answers
5k views

Using single characters for variable names in loops/exceptions

I've had a couple of discussions with a co-worker about the use of single letter variable names in certain circumstances inside our codebase, at which we both disagree. He favours more verbose naming ...
2
votes
2answers
100 views

Maintaining Method Signatures across languages?

I'm finishing up a port I did of a portion of a Java Library. The library calculates sunrise and sunset for a given latitude and longitude. The original Java library also calculated various times ...
1
vote
6answers
2k views

Static classes and/or singletons — How many does it take to become a code smell? [on hold]

In my projects I use quite a lot of static classes. These are usually classes that naturally seem to fit into a single-instance type of thing. Many times I use static classes and recently I've started ...
2
votes
3answers
326 views

C# Coding Standard - Position of Attribute in relation to Target

I had thought that this was one of the few solved problems in C# coding standards / style; Attributes always appear on the line above the thing to which they are applied a la [SomeClassAttribute] ...
8
votes
9answers
469 views

When, if ever, can code standards be ignored?

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 ...
10
votes
7answers
489 views

Introducing design concepts/patterns/principles to co-workers

I've read Joel's article about getting things done when you're a "grunt", several times in fact, but I've never been able to do any of the things it mentions. I work as part of a small development ...
18
votes
12answers
15k views

What does XXX mean in a comment?

What do people generally mean whenever you see XXX in a comment. Occasionally, I'll see a comment like this: # XXX - This widget really should frobulate the whatsit Of course, I can tell what the ...
101
votes
18answers
7k views

Can a function be too short?

Whenever I find myself writing the same logic more than once, I usually stick it in a function so there is only one place in my application I have to maintain that logic. A side effect is that I ...
2
votes
2answers
130 views

Is it good idea to write variable names that match application specific terms?

Let us say I am writing a Facebook like application. I write code like below $this->get_user_friends(); then next morning the boss says that we don't want to call Friends friends anymore, we ...
10
votes
8answers
502 views

What about all those coding rules?

I always supported the idea of having coding rules for developers in a company or a specific project. Especially if the company is size greater than 10. The bigger the company the bigger the need. I ...
12
votes
9answers
747 views

Does having to scroll horizontally make code less readable?

Well, does it? Is it considered bad practice? IMO, it is less readable. I hate having to scroll to the right, then back left, right, left, and so on. It makes coding more painful and confuses me ...
3
votes
5answers
1k views

How to not mix HTML with PHP?

I made an application in EXTJS, but my technical architect and project manager say we don't want big file, so removed the EXTJS and made in object oriented PHP and JavaScript code, mixing HTML with ...
10
votes
8answers
9k views

Best practices for constants

How do you guys handle constants, especially in Java (static final) and C++ (define)? Do you use dedicated headers (C++) or classes (Java) for all constants? Do you turn all literal values into ...
18
votes
9answers
1k 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? ...
56
votes
24answers
4k views

Is writing comments inside methods not a good practice? [duplicate]

A friend told me that writing comments inside methods is not good. He said that we should have comments only for the method definitions(javadocs) but not inside the method body. It seems he read in a ...
22
votes
21answers
5k views

Self Documenting Code Vs. Commented Code

I had a search but didn't find what I was looking for, please feel free to link me if this question has already being asked. Earlier this month this post was made: ...
5
votes
5answers
368 views

What are the standard practices for database access in .net?

I have seen weird database access practices in .net. I have seen stored procedures for every database tasks. I have seen every database property name is preceded by it's table name. I have seen fully ...
17
votes
8answers
1k views

Are 'edited by' inline comments the norm in shops which use revision control?

The senior dev in our shop insists that whenever code is modified, the programmer responsible should add an inline comment stating what he did. These comments usually look like // YYYY-MM-DD <User ...
1
vote
2answers
1k views

In general, which is better: Nested Grids, or Grids that include controls using Column/Row Spans?

This question has been in the back of my mind since I started with WPF and Silverlight. In general, is it better to use nested grids, or just set the Column/Row Span properties in a single Grid? ...
4
votes
5answers
486 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 ...
4
votes
1answer
105 views

What are the bundling/naming conventions for source-based packages?

Are there any conventions to use if I were to distribute the source for a C++ library I built? The plan is to use CMake as a build system, but for the rest I was wondering what are the standards in ...
3
votes
4answers
1k views

C/C++: Who uses the logical operator macros from iso646.h and why?

There has been some debate at work about using the merits of using the alternative spellings for C/C++ logical operators in iso646.h: and && and_eq &= bitand & bitor ...
1
vote
3answers
309 views

Use of c89 in GNU software

In GNU coding standard it is said that free software developer should use C89 because C99 is not widespread yet. 1999 Standard C is not widespread yet, so please do not require its features in ...
6
votes
5answers
290 views

Please help me give this principle a name [closed]

As a designer, I like providing interfaces that cater to a power/simplicity balance. For example, I think the LINQ designers followed that principle because they offered both dot-notation and ...
9
votes
9answers
439 views

Studies on code documentation productivity gains/losses

After much searching, I have failed to answer a basic question pertaining to an assumed known in the software development world: WHAT IS KNOWN: Enforcing a strict policy on adequate code ...