How are you adding comment sections to your source ?

Everything else that doesn't fall into one of the other PB categories.

What kind of comment sections are you using?

like style a)
0
No votes
like style b)
0
No votes
like style c)
4
20%
other styles ;) (please let us know how it looks like)
9
45%
WFT? I never comment anything :-P
7
35%
 
Total votes: 20

va!n
Addict
Addict
Posts: 1104
Joined: Wed Apr 20, 2005 12:48 pm

How are you adding comment sections to your source ?

Post by va!n »

Maybe a litttle stupid but on the other hand interesting point... How are you adding comment sections to your source!? What kind of are you using!?

Code: Select all

Style a)

; =============================================================================
; =
; =    P r o c e d u r e s
; =
; =============================================================================

Code: Select all

Style b)

; /////////////////////////////////////////////////////////////////////////////
; /
; /    P r o c e d u r e s
; /
; /////////////////////////////////////////////////////////////////////////////

Code: Select all

Sytle c)

; *****************************************************************************
; +
; *    P r o c e d u r e s
; *
; *****************************************************************************
va!n aka Thorsten

Intel i7-980X Extreme Edition, 12 GB DDR3, Radeon 5870 2GB, Windows7 x64,
Killswitch
Enthusiast
Enthusiast
Posts: 731
Joined: Wed Apr 21, 2004 7:12 pm

Post by Killswitch »

This is my standard program template. I change the second line to the program title (but in the same style i.e. ;\\-Program Name-----) and I also add other comments like so: ;\\Comment

It doesn't really add anything to the source, but it's just the way I do things :D.

Code: Select all

;\\------------------------------
;\\------------------------------
;\\------------------------------

 
;\\-Notes--
; Started:
; Completed:
; Version:
; Authors:
; Type: Program
;
;\\--------

;\\-Constants--------------------

;\\------------------------------

;\\-Structures-------------------

;\\------------------------------

;\\-Variables--------------------

;\\------------------------------

;\\-Includes---------------------
 
;\\------------------------------

;\\-Declares---------------------

  ;\\Misc
    Declare Error()
      OnErrorGosub(@Error())
  
;\\------------------------------

;\\-Main-------------------------
  

;\\------------------------------

;\\-Procedures-------------------
  
  ;\\Error

    Procedure Error()
      MessageRequester("Error",GetErrorDescription())
      End
    EndProcedure
  
;\\------------------------------

  End

;\\-End--------------------------
~I see one problem with your reasoning: the fact is thats not a chicken~
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post by Joakim Christiansen »

I made a screenshot to show how I like it... :
Image
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Re: How are you adding comment sections to your source !?

Post by traumatic »

Good programmers don't comment their code. It was hard to write, should be hard to read.
User avatar
Joakim Christiansen
Addict
Addict
Posts: 2452
Joined: Wed Dec 22, 2004 4:12 pm
Location: Norway
Contact:

Post by Joakim Christiansen »

traumatic wrote:good programmers don't comment their code. it was hard to write - should be hard to read!
I don't agree with you! :twisted:
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

Re: How are you adding comment sections to your source !?

Post by PB »

> How are you adding comment sections to your source!?

I agree with traumatic -- I don't comment unless I really think I need to.
Anyway, for short comments, I usually add to the end of a line or command:

Code: Select all

Sleep_(1) ; To not use 100% CPU.
If the line has several commands, I usually comment whatever is relevant:

Code: Select all

w=WindowWidth(0)+pgw : h=WindowHeight(0) ; pgw = PanelGadget width.
If a whole line needs commenting, or if the comment is long, I usually
comment the line above it:

Code: Select all

; Next line resizes the window to match the PanelGadget height.
w=WindowWidth(0)+pgw : h=WindowHeight(0)
If a few lines need commenting, I also comment the line above and put a
blank line above that and a blank line below, and call it a block:

Code: Select all

[...code...]

; This block resizes the window to match the PanelGadget height.
w=WindowWidth(0)+pgw
h=WindowHeight(0)

[...code...]
And lastly, if a block of code is very long, I comment like the above one
but add dashes to highlight the block to make it easier to see its start
and end points (although this example is not long, but you get the idea):

Code: Select all

[...code...]

; --------------------------------------------------------------
; This block resizes the window to match the PanelGadget height.
w=WindowWidth(0)+pgw
h=WindowHeight(0)
; --------------------------------------------------------------

[...code...]
And I actually have a new one now: If I have a massive block of code
that I re-use in all apps and it's 100% bug-free, I will now IncludeFile
it to save source size, because I know it'll work fine and I know what
it does, so I don't need the reassurance of seeing it in the main source.

Having said all that, you may see code in these forums by me that don't
conform to all that I've said above -- that's because I change my style
for public code, for whatever reason at the time. But for my own code,
that's how I do it.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post by Shannara »

I just use the comment character .....

Code: Select all

; This is a comment
User avatar
blueznl
PureBasic Expert
PureBasic Expert
Posts: 6172
Joined: Sat May 17, 2003 11:31 am
Contact:

Post by blueznl »

this is my (bad :-)) style...

Code: Select all

procedure.l abc(x.l,y.l,z.l)          ; this comment helps when folding, may list some parameters
  protected a.l, b.l
  global c.l
  ;
  ; *** describing again what the procedure does, but no desc. of parameters
  ;
  ; in:  x.l       - first parameter and so on, describe...
  ;      y.l = 1   - ah, a one
  ;          = 2   - oh! a two!
  ;      z.l       - no clue
  ; retval   = 0   - error
  ;          = 1   - no error
  ;
  ; here comes my code!
  ;
  ; *** prepare <-- using some stars to mark more important sections
  ;
  ; comments alore comments alore
  ;
  bla bla bla bla
  ;
  ;
  ; *** ah, another important part
  ;
  a = 1
  while a < 100
    ;
    ; keep on doing this
    ;
    a = a+1
    if a > 50          ; sometimes quick comments go here
      a = a+1          ; such as saying: speed up above 50
    else               ; do nothng, huh?
    endif
    ;
  wend
  ;
  procedurereturn 1
  ;
endprocedure
Last edited by blueznl on Mon Mar 06, 2006 10:17 pm, edited 1 time in total.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB - upgrade incoming...)
( The path to enlightenment and the PureBasic Survival Guide right here... )
User avatar
Guimauve
Enthusiast
Enthusiast
Posts: 742
Joined: Wed Oct 22, 2003 2:51 am
Location: Canada

Post by Guimauve »

My File Header

Code: Select all

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Project name : The name of the project
; File : The file name
; File Version : 0.0.0
; Programmation : To verify
; Programmed by : 
; Nickname : 
; E-Mail : 
; Date : 06-03-2006
; Last Update : 06-03-2006
; Coded for PureBasic V4.00
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
With jaPBe, in solid RED color, when the code is bugged and I need to stop for a long period.

Code: Select all

;/ <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
;/ <<<< LE DÉBOGGAGE C'EST TERMINÉ ICI <<<<
;/ Programmeur : Guimauve 
;/ Date : 06-03-2006 
;/ <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
The End Of File

Code: Select all

; <<<<<<<<<<<<<<<<<<<<<
; <<<< END OF FILE <<<<
; <<<<<<<<<<<<<<<<<<<<<
And my main source code template

Code: Select all

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; Project name : The name of the project
; File : The file name
; File Version : 0.0.0
; Programmation : To verify
; Programmed by : 
; Nickname : 
; E-Mail : 
; Date : 06-03-2006
; Last Update : 06-03-2006
; Coded for PureBasic V4.00
; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

IncludeFile "" 
IncludeFile "" 
IncludeFile "" 

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The StartCheckup routine <<<<<

StartCheckup()

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< Open Main windows <<<<<

ProgramNameWindow()

; <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
; <<<<< The events manager <<<<<

ProgramNameEventManager()

; <<<<<<<<<<<<<<<<<<<<<
; <<<< END OF FILE <<<<
; <<<<<<<<<<<<<<<<<<<<<
Regards
Guimauve
Post Reply