As long as there is some kind of standard in place, I’ll adapt to whatever it is.
But I agree 100% with Dave. Consistency is most important.
If there is no standard or it’s one of my own projects, I pretty much do the same thing as Paul but a little more.
I prefix controls etc:
txtTextField
cvsCanvas
btnButton
lblLabel
frmWindow (I think ‘frm’ came from Delphi with it’s Forms)
etc.
If there are (for example) two labels where the first one is fixed and the second changes like:
Username: John Smith
Then the first label is called:
lblUserNameTxt
and the second
lblUserName
I prefix standard properties like:
iInteger
bBool
dDouble
sString
And the rest with and ‘o’:
oPicture
oClass
oDictionary
oSomethingElse
Local variables and function/method parameters camelCase (with a descriptive name but no prefix).
I shadow subclass properties I’ve added to the inspector with my initials:
mhText
mhCaption
mhColor
I comment everything everywhere and use //:
// This is a
// comment block
ElseIf // Comment
And lastly global methods/functions in TitleCase and private/protected methods in camelCase.
That way, I don’t have to think and see immediately what it is. I do this since forever if whatever language I use allows me to.
I often see code from others where they write things like:
drawnow2 1,2,3,true
Instead of
drawCanvasImage(2, 1, 2, 3, True)
I think the second is more clear.
And in Xojo, I always use Jeremy’s Format Code script: https://github.com/jcowgar/xojo-format-code
I love that thingy.
I have a bad habit of using Len(int) instead of int.Len, Str(int) instead of int.ToText etc.
I guess I need to work on that.