Velocity Reviews - Computer Hardware Reviews

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

Reply
Thread Tools

Another style question

 
 
E. Robert Tisdale
Guest
Posts: n/a
 
      02-08-2004
Les Cargill wrote:

> I think it's possible to develop
> reasonably objective, nonrandom standards of readability.


I think that it's possible to develop several of them.

Take a look at the indent man page:

http://www.cs.umbc.edu/cgi-bin/man-cgi?indent

Look for the COMMON STYLES header.

> But some things done in the name of readability
> fly in the face of prohibitions against early return,
> some formatting conventions.


You probably need to distinguish
between *coding* styles and *programming* styles.

Coding styles are adequately handled by a program like indent
which will reformat your code for you.
Any attempt to impose a particular coding style is pure mischief.
You should develop or adopt a coding style and -- stick to it!
Consistency is most important in your coding style.
It will help you spot mistakes.
If other programmers need to read, understand and maintain your code,
they will quickly become accustomed to your style
or they will reformat it with indent.

Programming style, on the other hand, is something much more serious.
It's about nothing less than good programming practice --
developing good programming habits and avoiding bad programming habits.
For C programmers, it's about [self]discipline.
Good C programmers try to get their compiler to detect bugs for them.
They also include assertions to help them trap bugs at run time.
They use const to make their code easier for other programmers
to analyze. They avoid global and static variables.
They pass by value or const reference so that other programmers
need not be concerned about whether or not a function call modifies
its actual arguments. etc.

 
Reply With Quote
 
 
 
 
Rob Somers
Guest
Posts: n/a
 
      02-08-2004
"E. Robert Tisdale" <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> Ed Morton wrote:
>
> > Joona I Palaste wrote:
> >
> >> Can the C beautifier also beautify Java?

> >
> > Maybe, but I wouldn't trust cb with Java or even C++.
> > There are plenty of beautifiers
> > for those and other languages out there though, e.g. take a look at

>
> > http://ldp.homegrownhost.net/HOWTO/C...or_others.html

>
> BEWARE!
>
> Code "beautifiers" are not necessarily [style] reformatters.
> Most beautifiers insert text and embedded printer control sequences
> that your compiler will *not* accept.
>
> You also need to verify that
> reformatting did not change the meaning of your code.
> Always compile both the original and the reformatted versions
> of your code and verify that the resulting objects are identical.



Ok, how about gnu indent - is it to be trusted?
 
Reply With Quote
 
 
 
 
E. Robert Tisdale
Guest
Posts: n/a
 
      02-08-2004
Rob Somers wrote:

> Ok, how about gnu indent - is it to be trusted?


No.

But I must admit that I often use it without bothering
to check the emitted code for consistency.

Also, I always modify indent to format my C code
exactly the way I want it.
I probably shouldn't trust my modified version as much as I do
but the C compiler catches most of the mistakes right away
and I have been able to fix the bugs without much trouble.
So far, I haven't had any real problems with it.

 
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