What editor do you use, if it is notepad, please lie
a good style is a good style in Notepad, that is not dependent on syntax highlighting etc.
Please, have someone tell me that he does not use Notepad.
Code: Select all
;YES
;comment
;NO
; comment
;Indentation style - Wikipedia
;https://en.wikipedia.org/wiki/Indentation_style
;YES (Allman style)
Loop 3
{
MsgBox
Loop 3
{
InputBox Input
}
}
;NO (K&R: one true brace)
Loop 3 {
MsgBox
Loop 3 {
InputBox Input
}
}
;YES
if (var1 = var2)
;IT DEPENDS (But almost never)
if ( var1 = var2 )
;YES
oArray := ["a", "b", "c"]
;IT DEPENDS (But almost never)
oArray := ["a","b","c"]
;NO
oArray := [ "a", "b", "c" ]
;wtf is this
DllCall("MessageBox", Ptr,0, Str,"text", Str,"title", UInt,0)
;NO
DllCall( "MessageBox", "Ptr", 0, "Str", "text", "Str", "title", "UInt", 0 )
;NO
DllCall("MessageBox", "Ptr", 0, "Str", "text", "Str", "title", "UInt", 0)
;YES
DllCall("DllFile.dll\Function", "Ptr", 0, "Str", "text", "Str", "title", "UInt", 0)
;NO
MsgBox var "text" var var "text" "text" var "text"
;YES
MsgBox var . "text" . var . var . "text" . "text" . var . "text"
;NO (initial commas) (I do not use AHKv1. Still, I do not like the initial coma)
Loop, Parse, vText, `n, `r
;YES (no initial commas)
Loop Parse, Text, `n, `r
;NO (initial commas)
MouseGetPos, vCurX, vCurY, hWnd, vCtlClassNN
MouseGetPos,,, hWnd, vCtlClassNN
;YES (no initial commas)
MouseGetPos vCurX, vCurY, hWnd, vCtlClassNN
MouseGetPos ,, hWnd, vCtlClassNN
;NO
vText
oArray
;YES
text
array
xxx_xxx
; ... good
camelCaseForVars
CamelCaseForClasses
;YES
if !(var1 = var2)
if (var1 == "")
;NO
if not (var1 = var2)
if (var1 = "")
if var1 = var2
;YES
if (var1 && var2)
if (var1 || var2)
;NO
if (var1 AND var2)
if (var1 OR var2)
;OBVIOUSLY YES
var := "text"
var1 := var2
;OBVIOUSLY NO (NOTE: NOT AVAILABLE IN AHK V2)
var = text
var1 = %var2%
;NO ...
vText := "line 1`r`n" "line 2`r`n" "line 3"
;YES (the 'n' combines with the string)
Text := "line 1`r`nline 2`r`nline 3"
;cant recall the last time i had to put 2 consecutive spaces - me neither x2
;??
vText := A_Space A_Space
;??
vText := " "
;NO (indentation of 1 tab) (TAB? inconceivable)
if (var1 = var2)
MsgBox ; Oops! Sublime Text has replaced me TAB for spaces.
;strongly YES (indentation of 4 spaces)
if (var1 = var2)
MsgBox
;AMBIGUOUS CASES ...
;YES
if (var1 = var2)
MsgBox
;NO (UNNECESSARY CURLY BRACES)
if (var1 = var2)
{
MsgBox
}
if (var1 = var2) {
MsgBox
}
;IT DEPENDS
var := 1 + 1
;IT DEPENDS
var := 1+1