473,700 Members | 2,612 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1397
"maths_fan" <ma*******@mail .ru> wrote in message
news:c1******** *************** **@posting.goog le.com...
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*******@free net.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.pow ernet.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
19041
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 any preconceived ideas about it. I have noticed, however, that every programmer I talk to who's aware of Python is also talking about Ruby. So it seems that Ruby has the potential to compete with and displace Python. I'm curious on what basis it...
5
1760
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), cgi, fcgi, Webware, Zope, Plone, ...). Isn't there any article in style "this suite use this style of programming and is good for this type of applications"?
669
25965
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 paper written on this subject. On the Expressive Power of Programming Languages, by Matthias Felleisen, 1990. http://www.ccs.neu.edu/home/cobbe/pl-seminar-jr/notes/2003-sep-26/expressive-slides.pdf
8
2004
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, that's right, that's exactly what is said. People joining a team of developers are also encouraged to cooperate with their peers and adopt what has already been established right? Yes, that's exactly what is encouraged. Teamwork and cooperation...
100
4718
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 use comments. Thanks in advance! -- http://www.gotw.ca/resources/clcm.htm for info about ]
6
10714
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 graphic, with CSS only. the product is finished. whenever i select a color, its color will be displayed in a box whose id name is contained in variable "color_box" and the equivalent color value will appear in a text box with id contained in the variable...
3
1146
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 available, and the different style sheets written. I just need to know how to make it so that when you choose an option from the dropdown menu it changes the style sheet. Also if you know how to write a cookie to remember what style sheet the user...
46
2119
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 old-style function definition for 'main' Warning test2.c: 3 missing prototype for 'main' Warning test2.c: 3 ' Error test2.c: 3 compiler error in d:\lcc\mc71\types.c--assertion failure at line 868 Error c:\test\test2.c 3 Compiler error (trap)....
0
8639
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9203
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9058
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8952
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7794
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, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6555
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 presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5895
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4649
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2375
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.