Write Code Comments?
Write comments to describe the intended goal of a section of Power Apps code. Knowing the intended goal helps identify mismatches between it and the actual code outcome. Code that has comments takes significantly less time for other developers to understand.
Whether or not to write comments is an ongoing debate in the software development community. Do write comments into Power Apps code. Do not use comments as an excuse to write code with poor readability.
Commenting Style
->Use these commenting conventions to ensure a consistent style:
->Place comments on a separate line above the code section they are describing.
->Do not write in-line comments beside on the same line as a piece of code.
->Start comments with a capital letter
->End comment text with a period
Line Comments vs Block Comments
Power Apps has two comment styles: line comments and block comments. Line comments are made on a single-line and block comments can be made across multiple lines.
Comment Style | Syntax | Example |
Line | // [comment goes here] | // Validate the work order to submission. |
Block | /* [comments go here] */ | /* Work Order Details Screen: – Uses a single form to create, edit and view a record to minimize the number of controls in the app. – Emails a signed PDF to the employee’s manager after the form is submitted so it can be stored as backup. |
Tips For Writing Good Comments
->Do write comments that describe the intent of a code section. Intent means the goal.
->Do not write comments that simply restate what a line of code does. Writing clean code means other developers should be able to understand its function.
->Do keep comments updated when the goal of a code section changes.
->Do not write so many comments they are impossible to maintain. Comments create their own technical debt.
->Do write comments in full sentences and use plain language
->Do not use abbreviations, acronyms or slang