Tagged Questions
1
vote
4answers
355 views
Is using `continue`, `break` in non-`switch` loops and `?:` bad practice? [duplicate]
Back in college I've been told that using break; and continue; outside switch statements (e.g. to escape for or while loops) is wrong, bad practice and bad habits at the same time because it only ...
0
votes
2answers
216 views
Need some advice and feedback on my code's design
I am looking for feedback on the design of my program.
I have a shell script call function.sh that defines a lot of helper functions. My intent is to use those bash functions defined in functions.sh ...
1
vote
4answers
761 views
Should I use C style in C++?
As I've been developing my position on how software should be developed at the company I work for, I've come to a certain conclusion that I'm not entirely sure of.
It seems to me that if you are ...
1
vote
3answers
217 views
How to use correctly the comments in C/++ [duplicate]
Possible Duplicate:
Style and recommendations of commenting code
I'm learning to program in C and in my stage, the best form to use correctly the comments is writing good comments from the ...
7
votes
9answers
1k views
Is it any good to use binary arithmetic in a C++ code like “C style”?
I like the fact that the C language lets you use binary arithmetic in an explicit way in your code, sometimes the use of the binary arithmetic can also give you a little edge in terms of performance; ...
1
vote
4answers
355 views
Indenting labels in C
I noticed that in the Vim automatically indents labels in a rather unintuitive way (IMHO).
int main(void) {
goto end;
end:
return 0
}
Are there any style guidelines for labels?
For the ...
-1
votes
2answers
153 views
How should I group these variables?
I have a shape that will be defined by:
char s_type;
char color;
double height;
double width;
These variables are scanned in from a request string sent to my server and passed into my printing ...
6
votes
8answers
328 views
What is the possible disadvantage of putting declarations in inner blocks, instead of at beginning of function?
At the place where I work, there are explicit guidelines for placement of declarations of variables. According to that, it is required to put them at the global level and / or at the beginning of ...
4
votes
3answers
266 views
Do simple accessors and mutators benefit from commented block headers?
Short Question
Is it necessary to add the function header comments for simple accessors and mutators?
Example
u8 OBJ_get_state_x(void) {return obj.state_x;}
void OBJ_set_state_x(u8 x) ...
43
votes
16answers
3k views
Strictness in programming methods among Stack Overflow users [closed]
I've been a member of Stack Overflow for a couple of weeks now and have answered questions and read others answers, mostly in C/C++. True, I have learned about some things. For example, undefined ...
0
votes
2answers
494 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?
4
votes
7answers
358 views
Returning from a long function on the first false condition
I have a long(ish) function of the following pattern:
bool func(some_type_t *p1, another_t *p2)
{
bool a = false, b = false, c = false, etc = false;
a = (some_long && expression ...
4
votes
8answers
462 views
Programming style: Reoccuring error checks
Hey, I have a question about programming style, because in my current code I am using a bigger function which calls some smaller functions and all of these need to be error-checked. So something like ...
33
votes
15answers
9k views
If you need more than 3 levels of indentation, you're screwed?
Per the Linux kernel coding style document:
The answer to that is that if you need more than 3 levels of
indentation, you're screwed anyway, and should fix your program.
What can I deduce ...
11
votes
5answers
963 views
If you favor “T *var”, do you ever write “T*”? [duplicate]
Possible Duplicate:
int* i; or int *i; or int * i;
Thinking about where we place our asterisks; how do those that prefer to keep the "pointerness" away from the type and with the identifier ...