Re: Left brace on a single line -- Question
On 5 avr, 23:36, Erik Wikström <Erik-wikst...@telia.com> wrote:
> On 2008-04-05 22:11, Bryan Parkoff wrote:
> > I want to know the best practice to write on both C / C++
> > source codes. The best practice is to ensure readable.
> > Should left brace be after function or if on the same line
> > or next line.
> The best style is the one that is used in the code you are
> working in. If you are starting from scratch use whatever
> your IDE uses.
Do IDE's impose a style? Or even default to one? The editors I
use don't normally break a line just because you enter a brace;
if the brace is to be on a line by itself, you have to enter the
newline manually. (The editors do indent the next line
according to their idea of where it should be indented. I find
this mainly useful because if their idea of where it should be
isn't the same as mine, it often means I've forgotten to close a
parentheses.)
> Don't spend a lot of time on indentation and such, for most
> people it really does not matter once they get used to a
> style.
Within limits, and as long as it is consistent. (I'm old enough
to remember when no indentation was the most common style, every
line starting in column 1. Or column 7. No thank you.)
> I'll say this though, monitors are getting quite large these
> days and whitespace is cheep, your goal should always be to
> keep your code as readable as possible.
I don't understand the issue about white space. If you have to
indent more than three levels, for whatever reason, there's
something wrong. The monitor width is potentially valid with
regards to symbol length, but you shouldn't neglect the fact
that you might want to have a listing; I'd argue that the lines
should be short enough to fit horizontally on a page of A4
paper, in portrait mode, with a readable sized font.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
|