Upper case lower case conventions for screens, procedures, global variables and local variables names

I’m not a programmer but I’ve seen in some non App Inventor program listings that the case of the first letter of different parts of a variable or procedure name seems to follow a convention. In App Inventor are there any conventions for whether the first letter should be upper or lower case in the different parts that make up the name for a screen, procedure, global variable or local variable?

The following examples are not comprehensive and may or may not be correct conventionally but hopefully illustrate what I’m trying to understand:

  •   a screen name might be: StarDatabase
    
  •   a procedure name might be: setCalbrationFactor or SetCalibrationFactor
    
  •   a global variable name might be: 
                  global calibrationfactor or 
                  global CalibrationFactor; or 
                  global calibrationFactor 
    
  •   a local variable might be: calibrationFactor or CalibrationFactor
    

Is the case in any of these kinds of example important? Thanks for any advice, PeterO

for creating extensions there are the following conventions: UpperCamelCase for property, method and event names (i.e. the first letter should be a capital letter) and lowerCamelCase for parameter names

example:
naming

you can use the same conventions for your app

also @Peter came up with some naming conventions here

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by Taifun.

2 Likes

Hi Taifun,

That’s good and clear with very useful link and keywords for searching. Much appreciated.

A related question. When distinguishing between adjacent descriptive sections of a parameter name is it preferred to use an underscore or a capital letter? For example a parameter name: hourAngleDelay or hour_angle_delay?

Many thanks, PeterO

It is normal to just use capital letters for parameter names e.g. hourAngleDelay

1 Like

Many thanks Tim and Taifun, That’'s my issue completely resolved ánd I’ve just gone through the project following your advice.

Regards, Peter

I would recommend UpperCamelCase for project names, screen names, and component names, and lowerCamelCase for procedure names, parameters, and variables. In the case where a name might contain an initialism, only the first character of the initialism should be capitalized, e.g., JsonTextDecode, serviceUuid. This is the style we use for user-facing name items in the Java code (the only major difference is that non-user-facing method names use standard Java convention of lower camel case, e.g., getValue() not GetValue()).

I don’t necessarily include the type of a component in its name, I think it is better to name the component based on its purpose instead. For example, when I build HelloPurr, I’ll name the button Cat and the sound Meow so that the code reads when Cat.Click do call Meow.Play which is likely a bit easier for novices to parse than having Button1 and Sound1 or CatButton and MeowSound. This is more personal preference though and if you’re working on a project with someone it is good to establish agreed-upon conventions early in the process. For new users, I would strongly suggest that some type information in the name of the component is useful if you’re seeking help from the community as it’s easier to understand what’s going on, although I’m not sure I would advocate for Hungarian notation (e.g., btnCat) over something more verbose (e.g., CatButton).

2 Likes