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

learn more… | top users | synonyms (1)

518
votes
21answers
46k 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 ...
32
votes
6answers
4k views

Should interface names begin with an “I” prefix?

I have been reading "Clean Code" by Robert Martin to hopefully, become a better programmer. While none of it so far has been really ground breaking it has made me think differently about the way I ...
1
vote
2answers
414 views

Why would a video game need main(String[] args) in its own class?

My teacher just told me that whenever I create a class to run something for a video game company that uses Eclipse, I should make a run class with the main and any outputs. He says any arithmetic ...
17
votes
13answers
2k views

Is it an appropriate use of #define to make typing repeated code easier?

Is there any view on whether using the #define to define full lines of code for simplifying coding is good or bad programming practice? For example, if I needed to print a bunch of words together, I'd ...
0
votes
4answers
247 views

How do I convince some one that test should do assertion (not assertions) and not the helper methods

Joined a new employer and came across a new style of writing tests. @Test() public testMethodWhichDoesNotDoAnyAssertion() { LoginPage loginPage = signUpPage.doLogin("username","password"); ...
1
vote
4answers
237 views

What are the pros and cons of directly exposing a Table/View entity class to the client?

I'm developing a multi-tier application. We separate our project into three logical layers: client, service and data access. However, almost all methods in the service layer don't do anything except ...
5
votes
5answers
286 views

Standards in Enterprise Development

Is it perhaps time for enterprise systems to be developed to strict enforced standards? Many books list optional 'standards' and best practices, but these are purely suggested practices. Still, every ...
3
votes
7answers
5k views

Is there a common capitalization convention in C++? [closed]

I do a lot of work in Python and Java, and both those languages have fairly common (though not universal) conventions on how capitalization should be used in identifiers: both use PascalCase for class ...
19
votes
9answers
812 views

Is it better to use pre-existing bad practices, or good practices that don't fit well with old code? [closed]

I was thinking of this because I was trying to write an extension for an existing 3rd party software, and their database is horribly denormalized. I needed to use their existing tables and add a bunch ...
6
votes
5answers
2k views

Why do programmers use one-based indexing for line numbers in source code? [duplicate]

Possible Duplicate: Why isn't the line count in Visual Studio zero-based? Why isn't the top line in a source code file labelled line number 0? i.e. in a source file which was 10 ...
5
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 ...
76
votes
16answers
18k views

What is the benefit of not using Hungarian notation?

One of the things I struggle with is not using Hungarian notation. I don't want to have to go to the variable definition just to see what type it is. When a project gets extensive, it's nice to be ...
5
votes
1answer
679 views

Is there a standard pseudocode for parallel algorithms?

The common styles of pseudocode are largely intelligible, and it is more or less clear how to write pseudocode for sequential programs. But if parallelism is not hidden behind a full library and is ...
15
votes
5answers
876 views

What good reasons are there to capitalise SQL keywords?

There seem to be a lot of developers who write their SQL by capitalising the keywords: SELECT column FROM table INNER JOIN table ON condition WHERE condition GROUP BY clause HAVING ...
10
votes
8answers
2k views

Why did Microsoft make parameters, local variables and private fields have the same name naming convention?

I asked this question quite some time ago: How do you name your private variables in C#? In one of the answers, I was pointed to Microsoft's MSDN page that shows that private variables/fields should ...
2
votes
3answers
518 views

What are pros and cons of using temporary “references”?

In C and C++ (and I guess other languages that allow taking a "reference" to an array element or something similar), when you have an array like type, accessing individual elements of such an array ...
17
votes
3answers
2k 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
361 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 ...
38
votes
7answers
10k 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
1k 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
645 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 ...
3
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
470 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 ...
40
votes
13answers
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 ...
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 ...
18
votes
9answers
760 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
700 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 ...
71
votes
10answers
14k 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, ...
4
votes
13answers
744 views

Logging, do you do it? [closed]

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 ...
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 ...
65
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
429 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
302 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
483 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
667 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 ...
10
votes
3answers
604 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
454 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 ...
26
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 ...
55
votes
20answers
6k 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
102 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? [closed]

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
350 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
517 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 ...
11
votes
7answers
512 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 ...
21
votes
9answers
17k views

What does XXX mean in a comment? [closed]

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 ...
104
votes
18answers
8k 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
133 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
511 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 ...