PeopleCode | A basic template for creating an App Package class
A. First Things First
An Application Package offers a lot of flexibility in terms of defining methods, objects, functions and variables. These definitions include both existing PeopleCode constructs (such as ‘Declare Function’) along with constructs specific to the world of App Packages, such as defining methods and properties. Because there can potentially be a lot of elements to consider when developing an App Package, I often forget the correct order in which the definitions should be specified. For instance, if you have a Global variable where does that appear in the App Class code? What about a ‘Declare Function’ statement?
B. App Package Template
To give me some sort of starting point, I created the following App Package template.
/* Import App Package classes */ rem import PACKAGE1:CLASS1; rem import PACKAGE2:CLASS2; rem import PACKAGE3:*; class ClassName /* Set public properties */ rem property string Property1; rem property number Property2; rem property Record Property3; /* Define methods */ method ClassName(); method Method1(); method Method2(); method Method3(); private /* Set private instances */ rem instance string &instance1; rem instance number &instance2; rem instance Record &instance3; /* Define methods */ rem method Method4(); rem method Method5(); rem method Method6(); /* Set constants */ rem Constant &string1 = "CONSTANT1"; rem Constant &string2 = "CONSTANT2"; end-class; /* Declare Functions */ rem Declare Function FunctionName PeopleCode RECNAME.FIELDNAME FieldFormula; rem Declare Function FunctionName PeopleCode RECNAME.FIELDNAME FieldFormula; /* Define Global / Component variables */ rem Global file &fileLog; rem Component record &recName; /* constructor method */ method ClassName end-method; /* Additional methods */ method Method1 end-method; method Method2 end-method; method Method3 end-method;
This code can be copied and pasted into an App Package class. As a bare minimum to start with, update the name of the class to your own class name (do a search and replace on the ‘ClassName’ string). Then, the code can be saved.