The code-formatting tag has no wiki summary.
2
votes
4answers
829 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 ...
2
votes
1answer
122 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
121 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 ...
1
vote
1answer
125 views
String Formatting with concatenation or substitution [closed]
This is a question about preferences.
Assume a programming language offers these two options to make a string with some variables:
"Hello, my name is ". name ." and I'm ". age ." years old."
...
3
votes
4answers
131 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
184 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
276 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
162 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 ...
16
votes
7answers
938 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
182 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 ...
11
votes
4answers
4k 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
285 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
259 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
216 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
250 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
313 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
400 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 ...
0
votes
6answers
5k 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
188 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
2k 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
715 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
279 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 ...
5
votes
1answer
4k 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
441 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 ...
27
votes
30answers
5k 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 ...
12
votes
2answers
1k views
Best way to organize SQL queries stored in your code ? (or should you?)
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
167 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', ...
9
votes
7answers
3k 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 , ...
93
votes
37answers
49k 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())
{
...