Reusability and Object-Orientation
Large iXML codebases become maintainable only when reuse boundaries are explicit. iXML provides five primary mechanisms for structuring reusable code:
- Functions: Closed subroutines with local scope.
- Macros: Open subroutines that share the caller's context.
- Classes: Array prototypes for object-oriented design.
- Includes: External code source execution.
- Client Bindings: SOAP and REST service integration.
Each mechanism has different scoping, performance, and composability characteristics. Choosing the right one is critical for building robust ZeyOS applications.
Decision Framework
| Need | Recommended construct | Why |
|---|---|---|
| Small, context-aware template fragment | macro + expand | No context overhead; direct access to surrounding variables makes it natural for output patterns |
| Reusable logic with clear input/output contract | function + call | Context isolation prevents accidental side effects; parameters and return value create an explicit API |
| State and behavior that belong together | class + new | Properties hold state; methods provide behavior; inheritance enables hierarchical reuse |
| Code in a separate file or ZeyOS resource | include | Natural module boundary; local context provides isolation between files |
| External SOAP/REST web service | Client Bindings | Automatic WSDL/Route parsing; operations become callable functions |