@InvocableMethod does not need to be global beyond managed package scenarios. @RestResource aways needs to be global.

Clarify that System.debug is only sensitive in hot code code paths.
This commit is contained in:
Daniel Ballinger 2026-03-31 08:57:39 +13:00
parent 5a52a8a6ec
commit b29a3b532b

View File

@ -20,7 +20,7 @@ Gather or infer before authoring:
Defaults unless specified:
- Sharing: `with sharing` (see sharing rules per type below)
- Access: `public` (use `global` only when required by managed packages or `@InvocableMethod`)
- Access: `public` (use `global` only when required by managed packages or `@RestResource`)
- API version: `66.0` (minimum version)
- ApexDoc comments: yes
@ -93,7 +93,7 @@ If any constraint would be violated in generated code, **stop and explain the pr
| Use bind variables for all dynamic SOQL with user input | Prevent SOQL injection |
| Use Apex-native collections (`List`, `Map`, `Set`) rather than Java types | Prevent compile errors |
| Verify methods exist in Apex before use | Prevent reliance on non-existent APIs |
| Prefer structured logging over `System.debug()` | Debug string concatenation consumes CPU even when not observed |
| Avoid `System.debug()` in main code paths | Debug statements evaluate even when loggign is not active and consume CPU. Use a logging framework if required on main code paths |
| Never use `@future` methods | Use Queueable with `System.Finalizer`; `@future` cannot chain, cannot be called from Batch, and cannot accept non-primitive types |
### Bulkification & Governor Limits