Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C Programming (http://www.velocityreviews.com/forums/f42-c-programming.html)
-   -   What style to choose? (http://www.velocityreviews.com/forums/t315847-what-style-to-choose.html)

maths_fan 10-19-2003 01:43 PM

What style to choose?
 
What style do you prefer? Where to place brackets? How to name
variables, functions, constants, etc. How do you format your source
code? Do you write comments?

Mike Wahler 10-19-2003 05:34 PM

Re: What style to choose?
 
"maths_fan" <maths_fan@mail.ru> wrote in message
news:c13b5d9.0310190543.326b00a0@posting.google.co m...
> What style do you prefer?


Clear and readable.

> Where to place brackets?


Such that they contribute to the above.

>How to name
> variables, functions, constants, etc.


Such that they express their purpose.

> How do you format your source
> code?


Such that it's clear and readable.

> Do you write comments?


Yes, when they aid readability, otherwise not.

-Mike



Irrwahn Grausewitz 10-19-2003 06:38 PM

Re: What style to choose?
 
maths_fan@mail.ru (maths_fan) wrote:

>What style do you prefer?

Baroque.

>Where to place brackets?

On the wall.

>How to name
>variables, functions, constants, etc.

Pick random scrabble pieces out of a bag.

>How do you format your source
>code?

With an editor.

>Do you write comments?

No. The purpose of writing comments is to confuse the reader.
They're only useful in military strength code.

--
Irrwahn
(irrwahn33@freenet.de)

Malcolm 10-19-2003 07:17 PM

Re: What style to choose?
 

"maths_fan" <maths_fan@mail.ru> wrote in message
> What style do you prefer?
> Where to place brackets?

I always place brackets one above the other, and always have a bracket as
the only entry on its line.
> How to name variables, functions, constants, etc.

Generally I think one should use mathematical conventions - eg i for a loop
counter, x for a general real and y for a dependent one, N for a count etc.
An angle would be theta.
You do have problems with namespace collisions in C.
> How do you format your source code?

Without tabs, 2 spaces of indents.
>Do you write comments?

A function needs a comment to expalin what it does, what parameters it
takes, and what it returns. Usually heavy commenting of the function body
should be unnecessary because the function should be simple enough for
another programmer to see what is going on.



Richard Heathfield 10-19-2003 08:01 PM

Re: What style to choose?
 
Irrwahn Grausewitz wrote:

> maths_fan@mail.ru (maths_fan) wrote:
>
>>Do you write comments?

> No. The purpose of writing comments is to confuse the reader.


That is merely an unfortunate side-effect of badly-written or
poorly-maintained comments.

> They're only useful in military strength code.


All code should be "military" strength.

I know you're just winding the guy up, but it's fairly obvious that /he/
doesn't know that - hence this clarification.

--
Richard Heathfield : binary@eton.powernet.co.uk
"Usenet is a strange place." - Dennis M Ritchie, 29 July 1999.
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
K&R answers, C books, etc: http://users.powernet.co.uk/eton

Mathew Hendry 10-19-2003 09:29 PM

Re: What style to choose?
 
On 19 Oct 2003 06:43:51 -0700, maths_fan@mail.ru (maths_fan) wrote:

>What style do you prefer?


The one true style, obviously. :)

>Where to place brackets?


Cuddled except for function definitions, where they go one line under.

>How to name variables


By function.

>functions


By variable.

>constants


Constantly.

>How do you format your source code?


As I go... (seriously: adjusting formatting after the fact tends to confuse
version control systems).

>Do you write comments?


/* FIXME: broken */

(Yes, direct quote I'm afraid :)

Serious answer: simple, undertandable, consistent.

-- Mat.



All times are GMT. The time now is 05:40 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.