Jump to content

Recommended Posts

Posted (edited)

I know the topic is pretty dumb, but am curious as to how people structure their comments in regards to appending a full-stop or not?

From the beginning of my AutoIt "career" I used to write comments like...

; This is a simple comment.

But since moving onto other languages I have adopted the style of not appending a full-stop at the end of a comment line.

; This is a simple comment

Why? Well I think it looks pretty and saves me typing one more character which is never a bad thing.

Edited by guinness

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

Thanks @JohnOne, fixed it.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

WUT?  Don't ever let me catch you remarking without punctuation!

Outragious.

  Reveal hidden contents

 

Posted

I still prefer to use the style of your first example with a space after the comment start characters and a full stop after the sentence. I use the full stop because that's the sort of guy I am, and the fact that I that I tend to use blocks of comment, to describe the what the code is intended to do, which may consist of several sentences.

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

Posted

OK, cool.

Good point, I never do this either:

;Simple comment in AutoIt
//Simple comment in C#

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted

I like to do certain things in my comments, but I hardly ever do them consistently. 

I make a distinction between documentation comments and code disabling comments.

I like to put a space after the semicolon and append a full stop to my documentation comments.  I don't put a space after the semicolon when I'm temporarily disabling code.

Posted

Programming is hard enough as it is without meticulously watching your grammar in comments. They should be a quick way to show your thoughts as you were writing the code.

Why you're confused is that sometimes you do documentation of your code in comments. In C#, you can create neat summaries at the start of your function. You nearly always write those once the function prototype is complete and stable and you need to take your time to write it proper. Then you should also watch grammar.

Posted

I tend to use complete sentences in my comments, including the appropriate punctuation.  So, periods show up at the end.

; Now for something completely different.
; Even though the last line (and this one too) are not complete sentences.

David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

Posted

How complex is your code? Something like this, I would write maybe one comment, as the variables and structure are pretty easy to understand.

Local $sFile = 'ChromeEx.exe'

; Check if a filename is supported
Local $aSupportedFiles = ['Chrome.exe', 'Firefox.exe']
Local $bIsValidExe = False
For $i = 0 To UBound($aSupportedFiles) - 1
    If $sFile == $aSupportedFiles[$i] Then
        $bIsValidExe = True
        ExitLoop
    EndIf
Next

ConsoleWrite($bIsValidExe & @CRLF)

 

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

  • Moderators
Posted (edited)

For me (and I would guess for most others) it depends on the audience. If I am writing something just for me, a one line comment like guinness has above would suffice to jog my memory. If it is something I am handing off, not only will I comment heavily (usually with full stops), but I will often break the script up using #Region. I just wrote a script for a customer to uninstall a product, and cleanup files/folders/and registry entries for all users. That one looks a lot like so:

#Region=====================File System Variables============================
    ;Heavily Commented Code
#EndRegion==================File System Variables============================

#Region======================Registry Variables==============================
    ;Heavily Commented Code
#EndRegion===================Registry Variables==============================


#Region========================================File System================================================================
    #Region=============================remove user profile folders====================================================
        ;Heavily Commented Code
    #EndRegion=========================remove user profile folders======================================================

    #Region=============================remove system folders using dFOLDER array=======================================
        ;Heavily Commented Code
    #EndRegion==========================remove system folders using dFOLDER array=======================================

    #Region=============================remove single files using dFILE array===========================================
        ;Heavily Commented Code
    #EndRegion==========================remove single files using dFILE array===========================================
#EndRegion=========================================File System=============================================================


#Region==============================================Registry==============================================================

    #Region==========================================HKCR Keys===========================================================
        ;Heavily Commented Code
    #EndRegion=======================================HKCR Keys===========================================================

    #Region==========================================HKLM Keys===========================================================
        ;Heavily Commented Code
    #EndRegion=======================================HKLM Keys===========================================================


    #Region==========================================HKLM Values=========================================================
        ;Heavily Commented Code
    #EndRegion=======================================HKLM Values=========================================================

    #Region===========================================HKCU Keys==========================================================
        ;Heavily Commented Code
    #EndRegion=======================================HKCU Keys===========================================================
#EndRegion===========================================Registry==============================================================

Folding isn't exactly commenting, I know, and probably overkill, but I would rather that than someone calling six months later complaining I wasn't clear.

Edited by JLogan3o13

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Posted (edited)

Hi,

commenting code is one of my "vices". But i NEVER thought about to use a fullstop (at the end of a single line...)B)

Code must be "readable", including the comments. So i wrote a little script to align those comments, After pressing F4-key in Scite, the code looks (at least) good...  

This script could be expanded to put fullstops behind each Comment (or to erase them....)o:)

 

Edited by AndyG
Posted (edited)

Of course when developing with other people, the level of comments is increased tenfold. I should have been clear that I was talking about comments in code you write for your eyes only and not in a team.

Edited by guinness
Fixed typos

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted
  On 7/16/2015 at 7:30 PM, guinness said:

I should have been clear that I was talking about comments in code you write for your eyes only.

Is there a difference between your eyes and mines?

Maybe after some years an application controlled by my (your) script is changed by an update. The script contains ...pfff.. 500 to 1000 lines. You have to look at the code and have to adapt it too. Do you think after some years there is a difference if you need to adjust this script, or I?

I don´t think so. I sometimes have to debug code written by other programmers. The time to debug/change code depends on the quality of the comments and their (visual) reference to the code.

 

  On 7/16/2015 at 6:12 PM, JLogan3o13 said:

For me (and I would guess for most others) it depends on the audience. If I am writing something just for me, a one line comment like guinness has above would suffice to jog my memory. 

Lucky guys.^^

I am too old. For my brain it is better to jog with other things...

Posted
  On 7/17/2015 at 5:18 AM, AndyG said:

Is there a difference between your eyes and mines?

I fixed a couple of typos in that last post. I would say so, as I have different style than you do. This is why we kind of have standards, so it's not such a huge learning curve for everybody.

UDF List:

  Reveal hidden contents

Updated: 22/04/2018

Posted (edited)

This how i do it to answer your question

Local $sFile = 'ChromeEx.exe'

; Check if a filename is supported
Local $aSupportedFiles = ['Chrome.exe', 'Firefox.exe'] ; Files to search for
Local $bIsValidExe = False ; specify as a negative
For $i = 0 To UBound($aSupportedFiles) - 1 ; cycle through reducing, less 1 for the unbound
    If $sFile == $aSupportedFiles[$i] Then ; if file exists then
        $bIsValidExe = True ; set as true
        ExitLoop
    EndIf
Next

ConsoleWrite($bIsValidExe & @CRLF)

Ive just roughed this as its not my code but you get the idea.

I wish i didnt have a shocking memory but thats life ..

If i dont notate in  a months time i cant remember what the hell it was doing :) , prob why i ask so many questions lol

Edited by Chimaera
Posted

I would like to add my 2 cent:

Local $sFile = 'ChromeEx.exe'

; Check if a filename is supported
Local $aSupportedFiles = ['Chrome.exe', 'Firefox.exe'] ; Files to search for
Local $iLastFileIndex = UBound($aSupportedFiles) - 1 ; check for last index in array
Local $bIsValidExe = False ; initialization - specify as a negative
For $iFile = 0 To $iLastFileIndex ; cycle through reducing, less 1 for the unbound
    If $sFile == $aSupportedFiles[$iFile] Then ; if file exists then
        $bIsValidExe = True ; set as true
        ExitLoop
    EndIf
Next

ConsoleWrite('$bIsValidExe = ' & $bIsValidExe & @CRLF)

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted (edited)

I only heavily comment code if what I'm writing can't be figured out by the average coder. I may put a small snippet of comments in the code if it's for myself. Generally, if you need to over comment your code so you're able to follow it 6 months later, you're writing bad code. As for punctuation in the comments, I may put them if I think of it, otherwise who really cares if you put a period at the end of it?

Edited by BrewManNH
typo

If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

  Reveal hidden contents

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...