473,407 Members | 2,326 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

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?
Nov 13 '05 #1
5 1386
"maths_fan" <ma*******@mail.ru> wrote in message
news:c1*************************@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
Nov 13 '05 #2
ma*******@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
(ir*******@freenet.de)
Nov 13 '05 #3

"maths_fan" <ma*******@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.
Nov 13 '05 #4
Irrwahn Grausewitz wrote:
ma*******@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 : bi****@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
Nov 13 '05 #5
On 19 Oct 2003 06:43:51 -0700, ma*******@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.

Nov 13 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

220
by: Brandon J. Van Every | last post by:
What's better about Ruby than Python? I'm sure there's something. What is it? This is not a troll. I'm language shopping and I want people's answers. I don't know beans about Ruby or have...
5
by: Almad | last post by:
Hello, I'm currently starting with Python as a language for writing websites. I must say that I'm overwhelmed by the number of choices I have (mod_python with publisher, Vampire, mps, Spyce),...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
8
by: clintonG | last post by:
Every single time neophytes or converts ask about naming and style conventions what are they told by the majority consensus? The answer is "do what you prefer but do so consistently" right? Yes,...
100
by: Angel Tsankov | last post by:
Can someone recommend a good source of C/C++ coding style. Specifically, I am interested in commenting style and in particular how to indent comments and the commented code, rather than when to...
6
by: fallen angel | last post by:
halu there!! i'm a 1month experienced java scripter but got a good hang of it already. hehehe.. i developed a "color selection" tool, similar to the one in flash when you choose a color for a...
3
by: rodneyystwyth | last post by:
Does anyone know the code to have multiple css sheets on one website? Could you give me the exact code for xhtml to make it work. I have a drop down list with the options of different style sheets...
46
by: Kenny O'Clock | last post by:
This came up in a job interview, what is the output of the program below? I tried to compile and run it myself, but my compiler (lcc-win32) aborts with this errors.... Warning test2.c: 3 ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.