MaxScript Hungarian notation
MaxScript is a loosely typed language: a variable can indifferently hold any data type without the requirement to specify it upon creation. Language doesn't need a variable declaration before it can be used. A variable can therefore hold numeric data, character strings or 3ds Max Object references like Meshes, Cameras, Lights, Vertices, Edges or Faces selections, Modifiers, and so on. Loosely typed languages grant a great amount of flexibility, but it may easily become a drawback, because during the variable life, it can change value and data type too without breaking any language rule. Since MaxScript is an interpreted language, there's no type-check until the program is run and the specific variable is accessed.
In such environment as a program grows is easy to lose tracks about variables data types. Then the only way to retrieve it, is to go back to the place buried somewhere in the code where it was introduced and used for the first time. If it was initialized by receiving a function return value, it would be necessary to explore the function body and find out what it returns and so on recursively. This process it extremely slow and very time consuming.

During the first coding pass, it's easy to keep in mind variables meaning, their content and data type, but by reading the same code after months or even weeks can be challenging, since the whole context has faded. There are some best practices to help program writing and maintenance:

  • Give variables a meaningful name. There's nothing more obscure and frustrating than a poorly named variable.[1]
  • Choose an indent style and stick with it along the whole project. It helps consistency and improve readability.[2]
  • Use a simple unique style to represent variables name. Camel-case and underscore-separated compounds are common practices.
These recommendations are helpful for every programming language. For those loosely typed like MaxScript there's a further strategy for success:

In Hungarian notation, a variable name starts with a group of lower-case letters which are mnemonics for the type or purpose of that variable, followed by the name the programmer has chosen. The name part is capitalized, or the whole camel-case is applied to give a visual hint of the prefix.

Hungarian notation was invented by Charles Simonyi about three decades ago. After so much time from its introduction, the debate between its supporters and detractors is still alive. In my opinion it is a life saver in loosely typed languages like MaxScript, but doesn't have real meaning in strongly typed languages like C++, where you have to declare variables and their type, must explicitly do casts between types and the compiler is strict about type check.

In MaxScript the prefix can tell you at a glance what you're dealing with, being it a number, an Array and what it holds, a Structure and so on, without digging the code for the first use and avoiding to declare variables global to the whole Rollout or MacroScript for prompt access.

[1] McConnell, Steve (2004). Code Complete, Second Edition. Redmond WA, Microsoft Press. Chapters 10-13.
[2] Ibid. Chapter 31.
f       Float
i       Integer
n       Name
b       Boolean
s       String

p2      Point2           <x_float> <y_float>
p3      Point3           <x_float> <y_float> <z_float>
p4      Point4           <x_float> <y_float> <z_float> <w_float>

m3      Matrix3          <row1_point3> <row2_point3> <row3_point3> <row4_point3>
mx      Big Matrix       <rows_integer> <columns_integer>

q       Quaternion       <x_float> <y_float> <z_float> <w_float>

anga    Angle Axis       <degrees_float> <axis_point3>
ea      Euler Angles     <x_degrees_float> <y_degrees_float> <z_degrees_float>
r       Ray              <position_point3> <direction_point3>

b2      Box2             <x_integer> <y_integer> <w_integer> <h_integer>

c       Color            <r_float> <g_float> <b_float> [ <a_float> ] (0 ÷ 255)

mat     Material
tmap    Texture Map
bmp     Bitmap

t       Time

ca      Custom Attribute


a       Array
        a + Data Type + Name
        Array of Integers => aiName

ba      Bit Array


fn      Function

st      Struct
        publicStructMethod, publicStructProperty
        _privateStructProperty, _privateStructMethod


rol     rollout

ang     angle
bmp     bitmap
bt      button
cbx     checkBox
cbt     checkButton
cp      colorPicker
cmbx    comboBox
cc      curveControl
ddl     dropdownList
et      editText
gbx     groupBox
hl      hyperLink
it      imgTag
lb      label
lbx     listBox
mbt     mapButton
mtbt    materialButton
mlbx    multiListBox
pbt     pickButton
pum     popUpMenu
pbr     progressBar
rbt     radioButtons
sl      slider
sp      spinner
srol    subRollout
tm      timer