DEV Community

Peter + AI
Peter + AI

Posted on

πŸ”“ Understanding the Public Modifier in Uniface 10.4: Making Your Components Accessible

As developers working with legacy systems and modern integration requirements, understanding how to properly expose functionality in Uniface is crucial for building maintainable applications. Today, let's dive deep into the public modifier in Uniface 10.4! πŸš€

Note: This article is based on the official Uniface Documentation 10.4, and I had assistance from AI to structure this content.

🎯 What is the Public Modifier?

The public modifier in Uniface is your gateway to component interoperability. It modifies declarations to indicate that operations or handles are available for external use and can be called by other components. Think of it as the "export" mechanism in modern programming languages! πŸ“€

πŸ”§ Syntax Variations

Uniface offers several ways to use the public modifier depending on your needs:

πŸ“ Basic Operation Declaration

{public} operation OperationName
Enter fullscreen mode Exit fullscreen mode

πŸ”— Parameter Handles

{public} handle ParameterName : Direction
Enter fullscreen mode Exit fullscreen mode

πŸŽ›οΈ Variable Handles

{public} handle VariableName
Enter fullscreen mode Exit fullscreen mode

🌐 Web-Accessible Operations

public web
Enter fullscreen mode Exit fullscreen mode

🧼 SOAP-Accessible Operations

public soap
Enter fullscreen mode Exit fullscreen mode

πŸ“ Where Can You Use Public Modifiers?

βœ… Universal Support

  • public operation: Available in all component types
  • public handle: Available in all component types, plus fields, global variables, and component variables

🌐 Web-Specific Support

  • public web: Dynamic Server Pages, Static Server Pages, and Service components

🧼 SOAP-Specific Support

  • public soap: Service components, Dynamic Server Pages, and Static Server Pages

πŸ› οΈ How It Works Under the Hood

πŸ”„ Component Signature Integration

When you declare an operation as public, Uniface automatically includes it in the component signature. This means other components can discover and invoke these operations, enabling true component-based architecture! πŸ—οΈ

🌍 Web Integration

The public web declaration is particularly powerful - it allows operations and triggers to be activated by:

  • Browser requests 🌐
  • RESTful web services πŸ”—
  • Similar web clients πŸ“±

🧼 SOAP Integration

Using public soap enables operations to respond to SOAP requests, perfect for enterprise integration scenarios where SOAP is still prevalent.

⚠️ Important Gotchas

🚨 System Trigger Limitation:

System triggers cannot be declared with public web access level. Attempting to do so will result in compilation error:

error: 1000 - Public web access is not permitted for system triggers
Enter fullscreen mode Exit fullscreen mode

πŸ’‘ Practical Examples

🎯 Basic Public Operation

public operation getAccounts
    // Your account retrieval logic here
    // This operation can now be called by other components!
end
Enter fullscreen mode Exit fullscreen mode

🌐 Web-Accessible Operation

operation HelloWeb
public web
    // This operation can be triggered by web clients
    // Perfect for creating API endpoints!
end
Enter fullscreen mode Exit fullscreen mode

πŸŽ‰ Best Practices

  • 🎯 Be Intentional: Only make operations public if they truly need external access
  • πŸ“ Document Well: Public operations become part of your component's contract
  • πŸ”’ Security First: Consider authentication and authorization for web-accessible operations
  • πŸ§ͺ Test Thoroughly: Public operations should be robust as they can be called from various contexts

πŸš€ Conclusion

The public modifier in Uniface 10.4 is a powerful feature that bridges the gap between component isolation and integration needs. Whether you're building internal component communications, web APIs, or SOAP services, understanding these modifiers is essential for modern Uniface development! πŸ’ͺ

Happy coding! πŸ‘¨β€πŸ’»πŸ‘©β€πŸ’»

Top comments (0)