I know how you feel, it's really important to name the variables + subs in a way that in case there is a team member working on the same project with you he won't be lost.Hi all
One of the worst think about Programming is the names of the variables or methods or subs etc. As application grows up it is difficult to handle so many names. So if you can share you naming tips it will be wonderful.
Sub Class_Globals
Public gintValue As Int
Private mstrName As String
Type tPerson(strName As String, strSurname As String)
Ya, sorting the names following computer is important too. Use the same prefix for the same group of subs or database tables.to categorize the tables by number f.e.
001_XXXXXXXXXXXX base tables uniquely set.
070_XXXXXXXXXXXX many to many tables
090_XXXXXXXXXXXX supplementary tables needed for specific tasks.
Sub BtnProcess_Click
' Code
End Sub
Sub TextField1_TextChanged (Old As String, New As String)
' Code
End Sub
Sub SendData As ResumableSub
' Code
End Sub
Sub ProcessJob
' Code
End Sub
Sub Process_Globals
' Views
Private Label1 As Label
Private Label2 As Label
Private swBuild As B4XSwitch
Private TextField1 As TextField
Private TextField2 As TextField
Private TextArea1 As TextArea
Private BtnProcess As Button
' Variables
Dim strPath As String
Dim intCount As Long
End Sub
' Bad
Private Label1 As Label
Private Label2 As Label
' Good
Private lblFirstName As Label
Private lblLastName As Label
... is to categorize the tables by number f.e.
001_XXXXXXXXXXXX base tables uniquely set.
070_XXXXXXXXXXXX many to many tables
090_XXXXXXXXXXXX supplementary tables needed for specific tasks.
This might be interesting for you:if you can share you naming tips it will be wonderful
Hungarian notation named for Hungarian programmer Charles Simonyi, originator of WYSIWIG word processing at PARC and then moved to Microsoft initially to develop (Microsoft) Word. I imagine he was not too keen on reverting back to text mode displays, but you gotta work with what you've got."is sometimes called Apps Hungarian as it became popular in the Microsoft Apps division in the development of Word, Excel and other apps."
I wonder what they use instead. Knowing Microsoft, they probably name all variables as UUIDs that are parsed in 17 abstraction layers by 5 different systems. Joke aside, it would be interesting to know what they landed on.I also remember reading somewhere that Hungarian notation had fallen out of fashion at Microsoft.
Sub Process_Globals
' Views
Private 6f581b34-5087-4aa9-b1e5-830d4e257b55 As Label
Private f79d084d-e363-4036-962a-3064c4a0d836 As Label
Private 16d24b43-7194-4981-8904-c2cec2ca0105 As B4XSwitch
Private 659f7abd-27e4-4002-bea1-05088635a7b9 As TextField
Private e5798d37-0316-4813-8de2-59e3f44a3e2a As TextField
Private a402b560-1a93-44a2-886f-11b739d3f649 As TextArea
Private 74d745f3-ae35-4523-9492-71a4ee114bbc As Button
' Variables
Dim 577ad97e-30c3-44ae-b08d-ef6e4a992e7d As String
Dim 75816702-8696-4650-8df2-d3b6beb30c93 As Long
End Sub
I also remember reading somewhere that Hungarian notation had fallen out of fashion at Microsoft.
Joke aside, it would be interesting to know what they landed on.
A great feature: you can add comment lines to your methods (Subs) that contain code that you can copy and paste; even many lines of code.I like to add as many comments as I see needed to later understand why I did it that way.
' This routine is useful to...
' Example:
'<code>
' here many "ready" code lines that can be easily copied and pasted by just one click.
'</code>
Public Sub DoSomething
End Sub
https://www.b4x.com/android/forum/t...ily-your-own-code-snippets.126994/post-794854A great feature: you can add comment lines to your methods (Subs) that contain code that you can copy and paste; even many lines of code.
<code> ... </code>Before subs: Use \[ code] \[/code] inside comment for easy copy paste from examples
The most practiced way is to write them in capital letters and separate words by underscores. Remeber that in B4A underscores are used to prevent the obfuscation of the name.And what about Constants are you using all Capital Letters?
Not me, because already writing the signature of the function you can see the return type.And what about function names? Are you using any prefix indicating the return value or something else?
I use respectively:What about Classes, Modules, B4XPages, layouts etc.
Dim mean As Float = sum / n
Dim strMean As String = NumberFormat2(mean, 1, 4, 4, False)
Sub Class_Globals
Private xui As XUI
Private MP As B4XMainPage
Private callBack As Object
Private cv As B4XCanvas
Public name As String
End Sub
Public Sub Initialize(name_ As String, callBack_ As Object, cv_ As B4XCanvas)
MP = B4XPages.MainPage
name = name_
callBack = callBack_
cv = cv_
End Sub
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?