Table Of Contents: • Why Write Code Comments? • Commenting Style • Line Comments vs. Block Comments • Tips For Writing Good Comments
Why 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.
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.
|Line||// [comment goes here]||// Validate the work order to ensure it will not be rejected upon submission.|
[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
Use these suggestions to write high-quality 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
Did You Enjoy This Article? 😺
Subscribe to get new Power Apps articles sent to your inbox each week for FREE
If you have any questions about Power Apps Standards: Commenting Code please leave a message in the comments section below. You can post using your email address and are not required to create an account to join the discussion.