Prev: integer
Next: shared memory question
From: Lorenzo Villari on 24 Feb 2010 19:30 On 24 Feb 2010 22:09:43 GMT scott(a)slp53.sl.home (Scott Lurndal) wrote: > > if (condition) { > > is preferred over > > if (condition) > { > > Makes it much more likely that a properly written function will fit > on a single page/screen. Hmmm... if (condition) { <-- one line if (condition) <-- one line { <-- and another one, makes two lines Does that really make a BIG difference? > > In 30 years of C programming, no employer or project has used the > latter form. Really? What's so bad about that? I prefer the latter btw...
From: Ian Collins on 24 Feb 2010 19:43 Scott Lurndal wrote: > James Harris <james.harris.1(a)googlemail.com> writes: >> On 24 Feb, 20:53, BruceS <bruce...(a)hotmail.com> wrote: >> >> ... >> >>> I would like to add that, as long as you're trying to use good style, >>> for God's sake don't use the wrong indentation style. =A0If you put your >>> opening braces on the same line as your conditional, you'll just look >>> like a fool in front of your friends and colleagues. >> Snobbish nonsense! >> >> > > Indeed. > > if (condition) { > > is preferred over > > if (condition) > { By whom? > Makes it much more likely that a properly written function will fit on a single > page/screen. If the extra lines required for an opening brace are an issue, the function isn't properly written! > In 30 years of C programming, no employer or project has used the latter form. I can honestly negate that line. -- Ian Collins
From: Ike Naar on 25 Feb 2010 03:40 In article <Hshhn.9822$8y6.5647(a)news.usenetserver.com>, Scott Lurndal <slp53(a)pacbell.net> wrote: > > if (condition) { > >is preferred over > > if (condition) > { > >Makes it much more likely that a properly written function will fit on >a single page/screen. And then there are people who write like this: if (condition) { do_something(); do_another_thing(); }
From: Rainer Temme on 25 Feb 2010 04:56 > And then there are people who write like this: > > if (condition) { > > do_something(); > do_another_thing(); > } or like this: if (condition) { do_something(); do_another_thing(); } or even like this: if (condition) { do_something(); do_another_thing(); } .... the world is a cruel place!
From: Richard Bos on 25 Feb 2010 07:12
Seebs <usenet-nospam(a)seebs.net> wrote: > On 2010-02-24, Poster Matt <postermatt(a)no_spam_for_me.org> wrote: > > 5. On a slightly different note, I've been handling my error messages by using > > #define string constants in a header file. I saw some code which did this and it > > looked good to me. Is that standard practise, if not what is? > > > EG. #define ErrorDirNotFound "The directory was not found." > > No. Look into gettext() if you need to do this, or just put them in > literally. gettext() is nice if you have it (it's POSIX, isn't it? Not ISO, anyway, but common), but putting the messages in literally only works if you don't reuse them. IME, _some_ error messages are used more than once, in which case a #define is nice. Richard |