[Gambas-user] Better use of prefixes
Cedron Dawg
cedron at exede.net
Sat Mar 16 22:32:46 CET 2019
I like "suffix" rather than "postfix", but both are entirely understandable as well.
It's a matter of specificity precedence if I may abuse some language.
Do you like "perro negro" or "black dog"?
Jussi Lahtinen or Lahtinen, Jussi
I can totally understand once you get used to something, it becomes your preference. And preferences are just like opinions everybody..., ummmm, wait a moment, they are opinions.
Please tell my your opinion on this. Which version do you find more comprehensible? Quick, now.
http://gambaswiki.org/wiki/doc/naming
I could not find "ScrollBar" or "Container". Not sure where it is in the source tree either. So I'll guess "scb" and "cnt"
So my code:
'=============================================================================
Public Sub MoveVerticalSteps(ArgSteps As Float)
Dim theNewY As Float
Dim theContainer As Container
theContainer = myScrollBar.Parent
theNewY = myScrollBar.Y + ArgSteps * myScrollBar.H
If theNewY + myScrollBar.H > theContainer.H Then
myScrollBar.Y = theContainer.H - myScrollBar.H
Else If theNewY < 0 Then
myScrollBar.Y = 0
Else
myScrollBar.Y = theNewY
Endif
End
'=============================================================================
Becomes:
Dim fY As Float
Dim cntMain as Container
cntMain = scbMain.Parent
fY = $scbMain + fSteps * $scbMain.H
If fY + $scbMain.H > cntMain.H Then
$scbMain.Y = cntMain.H - $scbMain.H
Else If fY < 0 Then
$scbMain.Y = 0
Else
$scbMain.Y = fY
Endif
----- Original Message -----
From: "Jussi Lahtinen" <jussi.lahtinen at gmail.com>
To: "user" <user at lists.gambas-basic.org>
Sent: Saturday, March 16, 2019 5:13:55 PM
Subject: Re: [Gambas-user] Better use of prefixes
I like short variable names and I find prefixes aesthetically more pleasing than postfixes.
Thus I strongly prefer "btnThis" than "ThisButton". But both are fully understandable.
Jussi
More information about the User
mailing list