Coding Guidelines

From Xojo Documentation

Every developer and team should have coding guidelines to help ensure that code is readable by everyone on the team (or even yourself several months from now). There is no such thing as coding guidelines that everyone will agree with, but the guidelines described here are meant to be a starting point and match the coding guidelines generally used for the Xojo example projects and sample code that you see here in the documentation.

The most important thing is consistency, regardless of what guidelines you choose to use. Inconsistent code is more difficult to understand.


Term Definition
camel case The first "word" in the name is lower cased. Subsequent "words" are started with an upper case letter: customerName
title case All "words" in the name are started with an upper case letter: CustomerName


Having a consistent way to name the things in your project is an important first step in coding standards. Ideally coding standards will help others write correct code more easily and grasp existing code more readily.


  • Start with lower case "k", followed by title case: kMaxUsers.

Local Variables

  • Use camel case: Var customerName As String
  • Minimize use of abbreviations; spell things out. Use customerName, not custNm.
  • Use of single-letter variables names are acceptable for looping variables, such as used by For loops.


  • Should be plural: Customers() As Text


  • Use title case: CustomerName
  • A Private property that is the companion for a Computed Property should start with "m" and then be title case: mCustomerName.


  • Use title case: SaveCustomer
  • Method parameters should be camel case: SaveCustomer(customerName As Text)


  • Use title case, with a suffix indicating the type of control: OKButton. Below are some common suffixes:
Control Suffix Example
PushButton, WebButton, MobileButton, BevelButton Button SaveButton
ListBox, WebListBox List CustomerList
SegmentedButton, WebSegmentedButton, MobileSegmentedButton Selector TaskSelector
CheckBox, WebCheckBox Check TaxableCheck
PopupMenu, WebPopupMenu Popup StatePopup
RadioButton, RadioGroup Radio SourceRadio
TextField, WebTextField, MobileTextField Field NameField
TextArea, WebTextArea, MobileTextArea Area DescriptionArea
Canvas, WebCanvas, MobileCanvas Canvas GraphCanvas
Label, WebLabel, MobileLabel Label NameLabel
PagePanel Panel MainPanel
TabPanel Tab MainTab
ProgressWheel, ProgressBar, WebProgressWheel, WebProgressBar, MobileProgressBar, MobileProgressWheel Progress DownloadProgress
HTMLViewer, WebHTMLViewer, MobileHTMLViewer Viewer DocViewer
ImageWell, WebImageViewer, MobileImageViewer Image ProfileImage
GroupBox Group BusinessGroup

Classes (Types)

  • Use title case.
  • Subclasses of built-in classes should use original class name as suffix: CustomerListBox.


  • Use title case with "Window" as the suffix: CustomerWindow.


  • Use title case with "Interface" suffix.


  • Keywords should be in title case:
For Each c As Customer In Customers
  • Data types should be in title case:
Var count As Integer
  • Put spaces between all lists of arguments or parameters:
SaveCustomer(name, location, value)
  • Do not put spaces before or after parenthesis.
  • Methods called without parameters should not include empty parenthesis. Use:
instead of:
  • Methods with parameters should always include parenthesis. Use:

instead of:

MyMethod 42
  • Leave blank lines between code lines as appropriate to maintain readability.


  • SQL commands are written in uppercase:
    SELECT * FROM Team WHERE City = "Boston"


  • Var local variables near where they will be used with one declaration per line.
  • Methods not used outside the class/module should be Private.
  • Prefer dot notation over equivalent global methods when possible: Var length As Integer = customerName.Len
  • Never use Me when you mean Self.
  • Limit globals.
  • Prefer shared methods/properties on classes over global methods/properties on modules.
  • Classes, methods, properties, etc., within a Module or Class should be Private or Protected where possible.