focuses on legibility and consistent look of code: lexical-level intelligibility is a basic element of coding-style

learn more… | top users | synonyms

4
votes
3answers
192 views

Does code formatting have to matter?

UPDATE: an issue would arise from stuff that is not strictly defined by a formatter, like consecutive empty lines etc., that would get lost in the process (local to server to local reformatting) which ...
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 ...
2
votes
0answers
85 views

Erlang function naming conventions

I understand the general Erlang conventions for functions are using snake case or camel case, but what about exported functions? For example, say I have a gen_server module that defines a check to ...
2
votes
4answers
862 views

Identify this programming style

Some of the legacy code I've inherited uses the fact that C# supports multiple assignment to write code like: void DisableControls() { ddlStore.Enabled = ddlProgram.Enabled ...
1
vote
1answer
801 views

How to break these long C++ lines in a neat way? [closed]

I'm on my first bigger C++ project and find that I have some really long lines. My goal is to break them to 79 columns, but I do not really know how to do this in a neat way. Are there some guidelines ...
2
votes
1answer
142 views

How far to go when standardizing code [duplicate]

My small team and I have created a decent sized web application (~50k lines), with a fully featured API, all in Perl. As us perl hackers know.. it is easy to get sloppy. We had to port over a lot of ...
5
votes
2answers
133 views

Styling/formatting file for programmers, has it been done?

has there ever been a proposal for establishing a formatting style file for programmers? In web programming, we have CSS files that help separate style from 'code', so two people can see the same code ...
3
votes
4answers
137 views

Structuring an input file [closed]

I am in the process of structuring a small program to perform some hydraulic analysis of pipe flow. As I am envisioning this, the program will read an input file, store the input parameters in a ...
-1
votes
2answers
219 views

Why doesn't Python just establish a format for declaring tab widths?

I've read the flame wars over the use of spaces and tabs. When working with any markup language (when scope isn't very important and when pressing space 4 times is a PITA), I tend to minimize the tab ...
6
votes
3answers
298 views

Is there any situation in which it would be appropriate to use unless… else?

This construction is considered wrong unless #.. else #.. end This is for the general reason of double-negative confusions. It translates to: if not #.. if not not #.. end We all agree ...
0
votes
2answers
172 views

Code formatting for variable declarations [closed]

Is it looked down upon or bad to write multiple variable declarations on the same line? As in: boolean playMoreGames = true; int length; boolean win; int ...
15
votes
7answers
1k views

Should I write compact code or code with lots of spaces? [duplicate]

I have two friends that have completely different schools of thought on how to lay out their code. The first says that code should be well-indented and use lots of spaces and to name variables ...
3
votes
1answer
253 views

Chosing a parser for a code beautifier

I'm in the planning stage of making a code beautifier (similar to AStyle or Uncrustify) - originally I was going to just contribute to one of those projects, but reviewing their source led me to the ...
12
votes
4answers
6k views

Is it a good idea to format the code in eclipse using auto format

I use eclipse for coding, and the language which we use is Java. Once it was suggested by someone that to properly format the code, using the auto formatter(CTRL+SHIFT+F) While this command does ...
2
votes
2answers
3k views

Closest Point of Approach (CPA) mathematical formula in ship radar

I was recently searching for the mathematical formula to find closest point of approach (CPA) between one ship and another ship. I need to apply the formula in my radar ship program and I can't find ...
65
votes
17answers
6k views

Is imposing the same code format for all developers a good idea?

We are considering to impose a single standard code format in our project (auto format with save actions in Eclipse). The reason is that currently there is a big difference in the code formats used by ...
3
votes
1answer
302 views

Are there published guidelines, standards, or references that propose more than 80 chars per line?

Despite increases in screen size and resolution, many sources still suggest that code be limited to 80 characters per line. I realize than there are many different opinions on this subject, but I ...
0
votes
2answers
296 views

Indenting/formatting brackets like { } and [ ] [closed]

Is there an application that can easily align/format brackets such as [ ] { and } ? e.g. change { { } } into { { } }
-1
votes
1answer
232 views

Javascript Form Validation

When validating a JavaScript form, would it be better to process each input field individually, or, where possible check collectively? e.g. validate() { noblanks() fieldOne() ...
1
vote
3answers
268 views

How to work with badly written and formatted code

I was wondering how people deal with working in a project with badly written and formatted code, I'm talking mixed tabs and spaces, unnecessary parentheses and newlines and a whole bunch of warnings ...
4
votes
2answers
339 views

What code format has been verified by case studies as most readable? [closed]

Are there any eye tracking case studies, or similar research done to verify what code format is easiest to read, maintain and work with. I always format my code this way. function thing() { ...
10
votes
4answers
411 views

Is it a good practice to use Auto Format the text?

I'm using Eclipse and I will talk about it as an example but I am sure that this is the case in any other IDE. Eclipse has the CTRL-Shift-F command which automatically formats your code. Is it a good ...
1
vote
6answers
6k views

IF ELSE shorthand. Does it hurt readability [duplicate]

Possible Duplicate: Is the ternary operator evil? Does using shorthand if else statments hurt readability? Compare: string name = street != null ? street.Owner : "Not known"; With: ...
28
votes
14answers
4k views

Why isn't rich code formatting more common?

I was reading Code Complete and in the chapter on layout and style, he was predicting that code editors would use some sort of rich text formatting. That means, instead of code looking like this ...
3
votes
2answers
190 views

Parameter order: size, count or the other way round

I hope this is the right forum for this ... Well, in C, the standard library uses usually (void* buffer, int size) when referring to some data buffer. I wonder if there is a rationale for this order ...
7
votes
2answers
2k views

Algorithm for formating SQL code

I need a tool (for in house usage) that will format SQL code (SQL Server/MySQL). There are various 3rd party tools and online web sites that do it but no exactly how I need it. So I want to write my ...
8
votes
3answers
3k views

Closing tag (?>) on PHP files?

Some people swear by closing their PHP files with ?>, some say it's more optimized to leave it off. I know that it's not essential to have it on there, I'm just wondering what the pros and cons ...
22
votes
5answers
734 views

Formatting code a bad thing when using a VCS?

I almost always format my code before I commit to make sure it's done properly. Most of my team don't really care and don't always format their code properly (minor things that don't affect the code ...
8
votes
3answers
287 views

Code formatting : Laying out functions based on call hierarchy within a class file?

A suggestion from Bob Martin's "Clean code" has me scratching my head.. "If once function calls another, they should be vertically close and the caller should be above the callee" So far, I've been ...
-1
votes
7answers
264 views

Single line comments for multiple indented lines of code [closed]

After many years of coding, trying various programming styles, weeding out unreadable or impractical stuff, I still can't figure out one thing: what is the best way to single-line-comment multiple ...
6
votes
1answer
5k views

Header comment format

I realize that the "header comment" format varies from programmer to programmer, but what would be an example of a "good" header comment?
1
vote
3answers
525 views

Formatting PHP, what works more efficiently?

I was just wondering what makes PHP work faster. I have a few methods that I always go and do, but that only improves the way I can read it, but how about the interpreter? Should I include the curly ...
28
votes
30answers
7k views

Is it common to print out code on paper? [closed]

I like to keep my lines of code under 80 characters because: I don't have to do any horizontal scrolling; I know the line is probably too complicated if it exceeds this limit; and it prints out ...
13
votes
3answers
2k views

Best way to organize SQL queries stored in your code ? (or should you?) [closed]

I am sure I am not the only one who gets frustrated when they see a page of code littered with SQL queries. The ActiveRecord and other ORM patterns help mitigate a good amount of SQL used in a ...
0
votes
4answers
172 views

How do you format arrays within parameters?

I'm talking about something like this: echo $form->input('general_addresss', array( 'label' => 'Where will you go today?' 'format' => array('before', 'input', ...
10
votes
6answers
4k views

Code formatting SQL queries

Should I break SQL queries in different lines? For example in the project I am working on, we have a query that is taking 1600 columns! 1600 + tab chars. I wrote queries like this: "SELECT bla , ...
111
votes
37answers
62k views

Should curly braces appear on their own line? [closed]

Should curly braces be on their own line or not? What do you think about it? if (you.hasAnswer()) { you.postAnswer(); } else { you.doSomething(); } or should it be if (you.hasAnswer()) { ...