You are here: Best Practices > BML Coding Best Practices

BML Coding Best Practices

OVERVIEW

The purpose of good coding style is to write code that is readable. Readable code is easier to debug, extend, and modify, thus increasing your productivity and that of anyone else who will read your code. It is your duty as a programmer to adhere to style best practices.

Types of Coding Styles

ClosedStructural Coding Style

1. The Function Header should describe the entire script's salient properties.

2. Major sections of your code should be clearly marked and contain a brief explanation of its purpose, who wrote the code, and the date the code was written or modified.

3. Secondary sections of your code should also be clearly marked and contain a brief explanation, if necessary.

4. Group related lines of code together.

5. Follow conventional indentation and bracketing practices (alignment).


ClosedInline Coding Style

1. The name and format of a BML local variable should immediately communicate its purpose, intended behavior, and usage.

Local variables used as constants should:

Local variables used as variables should:

In all cases, the name of the variable should describe itself:

Variable names for Dictionaries should have the "Dict" suffix, and have a comment at the end of the declaration explaining the mapping between Key and Value:

Variable names for RecordSets should have the "Records" suffix:

  • For example, partRecords

Variable names for Booleans should have the "is" or "has" prefix (answered with a "yes/no" answer):

2. There should never be more than one statement on one line that is, never more than one semicolon ending a statement).

3. Print statements should be extricated from convoluted code and separated into a debug-flag controlled if block, and if it doesn't cause the code to become less readable.

4. Functions with a single argument should always enclose that argument in parentheses, for example, not(hasLicensing) rather than not hasLicensing.

5. Extremely long single-line statements, such as String concatenations, should be split across multiple lines.


NOTES

RELATED TOPICS

Related Topics Link IconSee Also