When working with Uniface applications, controlling the visibility and accessibility of operations and handles is crucial for maintaining proper encapsulation and security. Today, I'll dive into the partner
modifier - a powerful feature that helps you keep your components secure and well-structured. π‘οΈ
This article is based on the Uniface Documentation 10.4, with assistance from AI to help structure and present this information clearly.
π€ What is the "partner" Modifier?
The partner
modifier is a declaration keyword in Uniface that restricts access to operations and handles, making them available only within the component itself. Think of it as Uniface's way of implementing private visibility - similar to private methods in other programming languages! π
π Syntax and Usage
The partner
modifier can be used in several contexts:
π§ Operation Statements
partner operation OperationName
π Parameters Block
partner handle ParameterName : Direction
ποΈ Variables Block
partner handle VariableName
π Web Qualifier (Dynamic Server Pages)
partner web
π― Where Can You Use It?
- partner operation and partner handle: Available in all component types β
- partner handle: Can also be used for fields, global variables, and component variables π
- partner web: Specifically designed for Dynamic Server Pages π₯οΈ
π Key Benefits
π Component Encapsulation
When you declare an operation or handle with the partner
modifier, it becomes accessible only within the component itself. This promotes better code organization and prevents external components from accidentally calling internal methods.
π Web Security
In Dynamic Server Pages, combining partner
with the web
keyword adds an extra security layer. It prevents operations, detail triggers, or OnChange triggers from being directly invoked from the client browser - a crucial security feature for web applications! π‘οΈ
β οΈ Important Note for DSPs
While partner web
prevents direct browser invocation, the data specified in the scope declaration can still be included in DSP request-response exchanges of other triggers or operations. This gives you fine-grained control over what's accessible from the client side. π‘
π‘ Best Practices
- Use
partner
for internal helper operations that shouldn't be called externally π§ - Apply
partner web
to sensitive operations in Dynamic Server Pages π - Consider it as your "private" keyword equivalent in Uniface development π·οΈ
- Document your partner operations well since they're internal implementation details π
π Conclusion
The partner
modifier is an essential tool in the Uniface developer's toolkit for creating secure, well-encapsulated applications. Whether you're working with standard components or Dynamic Server Pages, understanding and properly using this modifier will help you build more robust and secure applications. π
Happy coding! π»β¨
Top comments (0)