Hi,
We have a scenario where a function has been marked as deprecated and is intended to be replaced with an alternative function.
I observed that:
- When using a deprecated activity inside another activity, Pega throws a guardrail warning while saving the rule.
- However, when using a deprecated function inside an activity, no such warning appears.
I would like to understand:
- Does Pega provide any mechanism to alert developers when a deprecated function is used in activity
- Are there any best practices to track and prevent the usage of deprecated functions across an application?
Any insights on this would be helpful.
Thanks,
@Ganesh Sankar
This answer is by a GenAI-powered tool. All generated answers require validation against the provided references.
Pega does have different behavior when handling deprecated activities versus deprecated functions within activities:
- Deprecated Activities: When a developer tries to use a deprecated activity inside another activity, Pega automatically displays a guardrail warning. This warning appears when saving the rule and requires justification before promotion.
- Deprecated Functions: Currently, Pega doesn’t have a built-in mechanism to automatically display guardrail warnings when deprecated functions are used within an activity. This explains why you don’t see warnings when using deprecated functions inside activities.
To address your specific questions:
Does Pega provide any mechanism to alert developers when a deprecated function is used in activity?
By default, Pega doesn’t automatically alert developers when deprecated functions are used within activities. However, there is a solution - you can implement custom guardrail warnings.
Best practices to track and prevent the usage of deprecated functions across an application:
- Implement Custom Guardrail Warnings:
- Create a custom activity named
CheckForCustomWarnings in the appropriate class
- Override the empty activity called
@baseclass.CheckForCustomWarnings
- Use the
default.pxAddGuardrailMessage function to add warnings for specific deprecated functions
- Place this in a ruleset accessible to all developers
- Maintain a Registry of Deprecated Functions:
- Create and maintain documentation of deprecated functions
- Include information about recommended alternatives
- Regular Code Reviews:
- Incorporate checks for deprecated functions during code reviews
- Use static code analysis where possible
- Automated Testing:
- Create test cases that specifically check for the use of deprecated functions
- Training and Awareness:
- Ensure developers are aware of which functions are deprecated
- Include this topic in onboarding and refresher training
- Monitor Compliance Score:
- Track your application’s compliance score over time
- Use it as an indicator of overall code quality, including the use of deprecated elements
The diagram illustrates the current process flow and highlights the gap in detecting deprecated functions within activities (in red), along with the proposed solution using custom guardrail warnings (in green).
By implementing these best practices, you can better manage and eventually eliminate the use of deprecated functions across your application, ensuring better code quality and easier future upgrades.
References:
Creating a custom guardrail warning
Best practices for application development
Custom guardrail warnings