Questions tagged [code-formatting]
focuses on legibility and consistent look of code: lexical-level intelligibility is a basic element of coding-style
60 questions
-2
votes
1
answer
124
views
Clean code: formatting rules, dependent functions, multiple calls [closed]
About formatting
Here are two scenarios in which the details of the formatting are described.
How should in the clean code way, this be formatted
Scenario 1: Dependent functions of dependent functions
...
1
vote
1
answer
896
views
How to integrate a profiler in the least invasive way possible?
I am currently using tracy to profile a program I am writing. Tracy as a tool seems quite awesome, but it has one issue.
You need to markup your code when profiling. This has the negative consequence ...
1
vote
2
answers
3k
views
C# convention for empty constructor [closed]
I know an empty method without any good reason is a code smell, but it can be required for constructors.
What would be a good way to write an empty constructor among the following?
class A
{
...
-1
votes
2
answers
620
views
What arguments in favor of automatic, mandatory, uniform code formatting in a software project? [closed]
I am the manager of a small team of software engineers.
I am looking for arguments in favor of automatic, mandatory code formatting.
For me it is natural, it goes with the Quality Assurance process ...
2
votes
2
answers
399
views
Where to put private computed properties?
In Clean code it's suggested that private helper functions should always exist directly below the function they're directly used within. Should I be doing this when using computed properties? It's the ...
3
votes
1
answer
477
views
Workflow for git / code formatting / commit hooks etc
Our team is growing, and with it, discontent with common coding standards being imposed on developers with alternate (strong, bordering on religious) views on what constitutes a good coding style.
...
8
votes
12
answers
7k
views
How small should functions be?
I'm new at writing professional code (the bulk of my experience is with personal projects) so excuse me if this is trivial. When I write code I find myself being a little inconsistent with how much ...
1
vote
0
answers
134
views
Alternative to reorder c++ tokens
Our organization is looking to standardize the way we use const T& and T const& and while we initially looked at clang-format to solve the job, it doesn't reorder tokens so there is no way to ...
3
votes
3
answers
3k
views
Including the type name in a variable name
Abstract: Is it acceptable to include the type name in the variable name?
My scenario:
I am working with C# MVVM, and I have a lot of ICommand properties in my ViewModel, named various things like ...
1
vote
2
answers
6k
views
What's the use of lint warnings vs errors? [closed]
I'm hoping someone who's given this some thought can help me understand. Most style-checking tools seem to distinguish between warnings and errors.
To me, the point of a lint error is that a style ...
0
votes
1
answer
340
views
Changing repetitive code to improve good programming design
In Java Swing if you want to add a listener to a component, it would look something like this...
JButton j = new JButton();
int counter = 0;
j.addAncestorListener(new AncestorListener() {
@...
2
votes
1
answer
310
views
What is the name/origin for this C code indentation style?
Look at the formatting of the variable declarations. I haven't encountered this indentation style in the past, but lately I stumbled upon two different code examples which use this style. Where does ...
5
votes
3
answers
401
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 ...
7
votes
1
answer
2k
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 ...
8
votes
1
answer
29k
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 ...
6
votes
2
answers
237
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 ...
0
votes
2
answers
1k
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 ...
0
votes
2
answers
313
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 ...
7
votes
1
answer
1k
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 ...
97
votes
17
answers
22k
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 ...
-1
votes
1
answer
367
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()
fieldTwo(...
7
votes
2
answers
1k
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 the following way:
function thing()
{
...
2
votes
6
answers
28k
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:
string name;
...
4
votes
2
answers
250
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 ...
20
votes
3
answers
14k
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 ...