/ doc / namingconvention
Variable calling convention
Written by Fabien Bodard

It's simply how you give name to your variables ! What method, to make difference between to type of variables or to type of objects.

#### You need to adopt a convention.

If you call each variable, according to the impultion of the moment, not only you will have names that you don't remember, but you will search astute variable name at place of seaching astute algorithms. A calling convention need to be automatic. In fact, two person that use the same calling convention would have the same variables name.

Most of the time, bad calling convention goes from pair with a bad code.

By default, Gambas give a default name to the widgets, like button1, textbox1, etc... and then incrementing the value when you add a new component in the IDE. But the problem with this system is that your code is really difficult to interpret or to debug...

But all is not lost at this time... i've maybe a soluce for you :-).

#### The hungarian convention for Gambas

The hungarian convention is a good one. You have probably seen this convention in some Microsoft Visual Basic exemples sources. I don't say it's the better one, but i've use it in some other languages php, fortran, and it got fine on Gambas.

All the users of the hungarian convention that i know have in a first time hated it. But whatever your opinion is, you will not regret having learned to read Hungarian. This convention was created by Charle Simonyi, veteran of developement at Microsoft and and Hungarian of birth. It implies that the variables comprises two parts: a basic type in small letters indicating the kind of variable, and a qualifier with initial in capital letter which distinguishes a variable of the other of the same variables. Then you can a letter like $ at the end to distingish the global variables.

### Examples

    An integer variable that will be used to locate something
    iPos

    An integer variable that will be used to locate something in a file and another in a textarea
    iFilePos
    iLinePos

    A form for save a file as...
    frmSaveFileAs

### Prefix convention for common variables types

Variable type | Prefix
--- | ---
Integer | i
Float | f
Boolean | b
Byte | bt
Short | sh
Long | l
Single | sng
Variant | v
Pointer | ptr
String | s
Date | date
Object | o

### Prefixe convention for array or collection variable type

Variable Type | Prefix
--- | ---
Static array | ar + type prefix
Integer[] | ari
Float[] | arf
Boolean][] | arb
Byte][] | arbt
Short[] | arsh
Long[] | arl
Single[] | arsng
Variant[] | arv
String[] | ars
Date[] | ardate
Object[] | aro
Collection | col

### Special types

Variable Type | Prefix
--- | ---
File | fi
Process | proc

### Some Component prefix example

Variable Type | Prefix
--- | ---
Form | frm
TextBox | txtb
TextArea | txta
ListBox | lstb
ComboBox | cbo
Timer | tmr
Button | but
ToggleButton | tglbut
ToolButton | tbut