473,472 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Comment Styles

RedSon
5,000 Recognized Expert Expert
So what do you guys use for headers to your files or headers for each individual method. If you write java don't respond to this thread.

Something like:

Expand|Select|Wrap|Line Numbers
  1. ////////////////////////////////////////////////////////////////
  2. // File: foo.cpp
  3. // Description: Takes a snarbleblart and applies the merkalanium transform to output a booblenortrox.
  4. // Author: RedSon
  5. /////////////////////////////////////////////////////////////////
  6.  
  7. et cetra, et cetra....
  8.  
Jan 25 '07 #1
4 1056
Ganon11
3,652 Recognized Expert Specialist
Informally (as I'm only a high school student doing assignments for my teacher), my header looks something like

Expand|Select|Wrap|Line Numbers
  1. /* Chapter X, Exercise Y (or substitute for Exercise, as we may be working off of a handout)
  2. Class Name (Independent Study), Name */
For some of my recent independent (read: fun) projects, I've bee adding a "Date last modified" section, a name, a brief description of the project and a mock "version".

For methods, I rarely comment, but when I do I include a brief description including what the function basically does, sometimes how it works, the postconditions and preconditions, and the return value - what it could be and what it specifies. So the comment might be (from my latest project, Chess):

Expand|Select|Wrap|Line Numbers
  1. // boolean whiteInCheck()
  2. // whiteInCheck() loops through every possible space on board.
  3. // If there is any piece that can legally capture the White King
  4. // (it has 'line of sight' and is a Black piece), then the function
  5. // immediately returns true.  If the loops finish, then no piece
  6. // threatens the White King, and there is no check.  The function
  7. // returns false.
  8. // Pre-condition: board has been initialized to a 2D array of
  9. //                chessPieces (8 x 8)
  10. // Post-condition: Indicates whether the White King is in check.
  11. // returns: boolean - True = White King in check, false = No check
Jan 25 '07 #2
r035198x
13,262 MVP
Informally (as I'm only a high school student doing assignments for my teacher), my header looks something like

Expand|Select|Wrap|Line Numbers
  1. /* Chapter X, Exercise Y (or substitute for Exercise, as we may be working off of a handout)
  2. Class Name (Independent Study), Name */
For some of my recent independent (read: fun) projects, I've bee adding a "Date last modified" section, a name, a brief description of the project and a mock "version".

For methods, I rarely comment, but when I do I include a brief description including what the function basically does, sometimes how it works, the postconditions and preconditions, and the return value - what it could be and what it specifies. So the comment might be (from my latest project, Chess):

Expand|Select|Wrap|Line Numbers
  1. // boolean whiteInCheck()
  2. // whiteInCheck() loops through every possible space on board.
  3. // If there is any piece that can legally capture the White King
  4. // (it has 'line of sight' and is a Black piece), then the function
  5. // immediately returns true.  If the loops finish, then no piece
  6. // threatens the White King, and there is no check.  The function
  7. // returns false.
  8. // Pre-condition: board has been initialized to a 2D array of
  9. //                chessPieces (8 x 8)
  10. // Post-condition: Indicates whether the White King is in check.
  11. // returns: boolean - True = White King in check, false = No check
And how far are you with this one?
Jan 26 '07 #3
Ganon11
3,652 Recognized Expert Specialist
And how far are you with this one?
Close - very close. I finished the rules for Castling this morning, then I'll have to make slight changes to the Pawn type, and then testing begins.
Jan 26 '07 #4
r035198x
13,262 MVP
Close - very close. I finished the rules for Castling this morning, then I'll have to make slight changes to the Pawn type, and then testing begins.
You won't have to worry about where to get testers
Jan 26 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Quinton | last post by:
I'm running a website that uses CSS to format the text and a CGI program Coranto that icludes news updates via SSI. My problem is that some parts of the CSS don't seem to take effect on the...
3
by: Matt | last post by:
I am new to CSS. When we write the CSS for the position settings, do we need to type it manually. Or it can be done by editor? also, I want to make sure /* */ is the syntax to comment. Please...
12
by: dan.vendel | last post by:
Hi, I know nothing about javascript, but quite a lot about regulat html and CSS. Have bumped into a problem that people in this fine congregation perhaps can help me with. I'm making a...
3
by: JezB | last post by:
What's the generally accepted approach for using Styles and Stylesheets in a web application based on .aspx files, Web Controls, User Controls, and code-behind modules (c# in my case)? Most style...
7
by: sasquatch | last post by:
Hi, I've a a site with nested master pages and content pages. I tried using a theme with a stylesheet in the app_themes directory referencing it in the web.config file from a pages tag theme...
6
by: carolyn | last post by:
I am trying to figure out if there is meaning to a comment "/* \*/" or if I am reading too much into it. I am reworking some stylesheets and came across the /* \*/ in the document a number of...
18
by: pocmatos | last post by:
Hi all, While I was programming 5 minutes ago a recurring issue came up and this time I'd like to hear some opinions on style. Although they are usually personal I do think that in this case as...
3
by: spolsky | last post by:
hi, it is possible to apply multiple styles as shown in the following example. <STYLE TYPE="text/css"><!-- BODY { background-color:salmon; } P { margin-left:20px; } .clsCode {...
0
by: matt urbanowski | last post by:
Hi, I have a calendar control on a form in VS2003 and have applied some styles to it. I have separate styles for all of the groups e.g. DayHeaderStyle, DayStyle, NextPrevStyle etc. and one for the...
4
by: splounx | last post by:
Hi there, I am a relative CSS & JavaScript novice and I have a particular problem that is beyond my level of knowledge so I thought I'd tap the collective wisdom of this group. I would like...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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 project—planning, coding, testing,...
0
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
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.