Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Another style question

Reply
Thread Tools

Another style question

 
 
Christopher Benson-Manica
Guest
Posts: n/a
 
      02-05-2004
Joona I Palaste <> spoke thus:

> Christopher originally wrote "nitpicky", not "anal". It's fun to see
> what Trollsdale will alter *my* message to. =)


Well, in this case at least it's fairly benign - one might call it
un-euphemizing my choice of words

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
 
Reply With Quote
 
 
 
 
Programmer Dude
Guest
Posts: n/a
 
      02-05-2004
Christopher Benson-Manica wrote:

> How about your if/else if/else constructs?


if (cond) { /* brace can be here... */
/* ... */
}
else
if (cond) /* ...or line below... */
{ /* (depending on what looks best at the time) */
/* ... */
}
else /* ...but never after final else */
{
/* ... */
}

--
|_ CJSonnack <> _____________| How's my programming? |
|_ http://www.Sonnack.com/ ___________________| Call: 1-800-DEV-NULL |
|_____________________________________________|___ ____________________|
 
Reply With Quote
 
 
 
 
Dan Pop
Guest
Posts: n/a
 
      02-05-2004
In <bvrj10$ofn$> Joona I Palaste <> writes:

>Personally I'm a bit of a style Nazi myself. Whenever I have to edit
>code someone else wrote, I take time to format it to "readable" style
>first. Which means:


Which means that you've never been involved in some open/free source
code collaboration, where the ability to produce and read *meaningful*
diffs is essential. Any stylistical changes to the code are a major
source of "noise" and the rest of the collaboration would promptly
kick you out.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email:
 
Reply With Quote
 
Dan Pop
Guest
Posts: n/a
 
      02-05-2004
In <> CBFalconer <> writes:

>Richard Heathfield wrote:
>> Thomas Stegen CES2000 wrote:
>> > Joona I Palaste wrote:
>> >
>> > I think I would object if someone told me to code like this though:
>> > a=b+c*3;
>> > I think a = b + c * 3; is much better.

>>
>> And I prefer
>>
>> a = c * 3 + b;
>>
>> YMMV.

>
>Definitely MV. I can even find cases where I want different
>emphasis, and would write:
>
> a = 3*c + b;
>or
> dsq = b*b - 4*a*c;
>
>although normally I would not suppress the blanks.


As a beginner, I would not insert any space that was not required by the
language. A habit inherited from FORTRAN programming on punched cards,
where you really wanted to avoid continuation cards. Then, one day I was
bitten by

i=-1;

being parsed as

i =- 1;

by a VAX C compiler (=- was the anachronic form of -=, but some
pre-ANSI compilers still supported it). After that, I always left one
space between operators and operands, just to be on the safe side. This
kind of bugs (the compiler parses the code differently than the human) is
just too difficult to spot, so it pays the "effort" needed to avoid it.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email:
 
Reply With Quote
 
Joona I Palaste
Guest
Posts: n/a
 
      02-05-2004
Dan Pop <> scribbled the following:
> In <bvrj10$ofn$> Joona I Palaste <> writes:
>>Personally I'm a bit of a style Nazi myself. Whenever I have to edit
>>code someone else wrote, I take time to format it to "readable" style
>>first. Which means:


> Which means that you've never been involved in some open/free source
> code collaboration, where the ability to produce and read *meaningful*
> diffs is essential. Any stylistical changes to the code are a major
> source of "noise" and the rest of the collaboration would promptly
> kick you out.


You guessed right. The only "real" programming I've ever done is for
university exercises and an actual commercial job. With both of these,
a change that does nothing else than make the code more readable is
accepted.

--
/-- Joona Palaste () ------------- Finland --------\
\-- http://www.helsinki.fi/~palaste --------------------- rules! --------/
"The truth is out there, man! Way out there!"
- Professor Ashfield
 
Reply With Quote
 
Mark McIntyre
Guest
Posts: n/a
 
      02-05-2004
On 5 Feb 2004 18:02:56 GMT, in comp.lang.c , Joona I Palaste
<> wrote:

>Dan Pop <> scribbled the following:
>> In <bvrj10$ofn$> Joona I Palaste <> writes:
>>>Personally I'm a bit of a style Nazi myself. Whenever I have to edit
>>>code someone else wrote, I take time to format it to "readable" style
>>>first. Which means:

>
>> Which means that you've never been involved in some open/free source
>> code collaboration, where the ability to produce and read *meaningful*
>> diffs is essential. Any stylistical changes to the code are a major
>> source of "noise" and the rest of the collaboration would promptly
>> kick you out.

>
>You guessed right. The only "real" programming I've ever done is for
>university exercises and an actual commercial job. With both of these,
>a change that does nothing else than make the code more readable is
>accepted.


Its also worth noting that any code diff or version control tool that
takes meaningless whitespace into account should be abandoned. It
should always be possible to beautify dense code without aggravation.

--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
 
Reply With Quote
 
Christopher Benson-Manica
Guest
Posts: n/a
 
      02-06-2004
Mark McIntyre <> spoke thus:

> Its also worth noting that any code diff or version control tool that
> takes meaningless whitespace into account should be abandoned. It
> should always be possible to beautify dense code without aggravation.


Believe me, if it were in my power to use something other than
Microsoft's Visual Sourcesafe at my employment docimile, I certainly
would.

--
Christopher Benson-Manica | I *should* know what I'm talking about - if I
ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
 
Reply With Quote
 
Dan Pop
Guest
Posts: n/a
 
      02-06-2004
In <bvu0gg$7gj$> Joona I Palaste <> writes:

>You guessed right. The only "real" programming I've ever done is for
>university exercises and an actual commercial job. With both of these,
>a change that does nothing else than make the code more readable is
>accepted.


Keep in mind that readability is in the eye of the beholder. What's
more readable to you may be less readable to the person who wrote the
code in the first place. We had plenty of threads proving this, in this
very newsgroup.

The only consensus is that some form of indentation is better than
no indentation at all and that identifiers with meaningful names are
better than identifiers of the form oo0o00oo and l111ll1ll.

But once we start comparing the merits of different kinds of indentations
or identifier naming conventions, the Pandora's box is open...

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email:
 
Reply With Quote
 
Mark McIntyre
Guest
Posts: n/a
 
      02-06-2004
On Fri, 6 Feb 2004 02:18:06 +0000 (UTC), in comp.lang.c , Christopher
Benson-Manica <> wrote:

>Mark McIntyre <> spoke thus:
>
>> Its also worth noting that any code diff or version control tool that
>> takes meaningless whitespace into account should be abandoned. It
>> should always be possible to beautify dense code without aggravation.

>
>Believe me, if it were in my power to use something other than
>Microsoft's Visual Sourcesafe at my employment docimile, I certainly
>would.


the vesion of vss that I last used actually had an option to ignore
whitespace. STR that it didn't actually work as such tho....
--
Mark McIntyre
CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html>
CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>


----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
 
Reply With Quote
 
Les Cargill
Guest
Posts: n/a
 
      02-08-2004
Dan Pop wrote:
>
> In <bvu0gg$7gj$> Joona I Palaste <> writes:
>
> >You guessed right. The only "real" programming I've ever done is for
> >university exercises and an actual commercial job. With both of these,
> >a change that does nothing else than make the code more readable is
> >accepted.

>
> Keep in mind that readability is in the eye of the beholder. What's
> more readable to you may be less readable to the person who wrote the
> code in the first place. We had plenty of threads proving this, in this
> very newsgroup.
>
> The only consensus is that some form of indentation is better than
> no indentation at all and that identifiers with meaningful names are
> better than identifiers of the form oo0o00oo and l111ll1ll.
>
> But once we start comparing the merits of different kinds of indentations
> or identifier naming conventions, the Pandora's box is open...
>
> Dan
> --
> Dan Pop
> DESY Zeuthen, RZ group
> Email:


I think it's possible to develop reasonably objective, nonrandom
standards of readbility. But some things done in the name of readability
fly in the face of prohibitions against early return, some formatting
conventions.

--
Les Cargill
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Another style/readability question... jackassplus@gmail.com C Programming 3 03-17-2010 10:04 AM
All style tags after the first 30 style tags on an HTML page are not applied in Internet Explorer Rob Nicholson ASP .Net 3 05-28-2005 03:11 PM
Need help with Style conversion from Style object to Style key/value collection. Ken Varn ASP .Net Building Controls 0 04-26-2004 07:06 PM
Yet another nitpicky style question Christopher Benson-Manica C Programming 17 02-20-2004 09:03 PM
Style sheets, include one style within another (not inheritance) foldface@yahoo.co.uk HTML 1 11-24-2003 01:37 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57