WORKING-STORAGE SECTION for defining factory data
WORKING-STORAGE SECTION in the
DIVISION of the
FACTORY paragraph to describe
the factory data that a COBOL class needs, that is, statically
allocated data to be shared by all object instances of the class.
FACTORY keyword, which you must
immediately precede with an
IDENTIFICATION DIVISION declaration,
indicates the beginning of the definitions of the factory data and
factory methods for the class. For example, the definition of the
factory data for the Account class might look like this:
01 NumberOfAccounts pic 9(6) value zero.
. . .
You can initialize
simple factory data by using
VALUE clauses as shown
factory data is equivalent to Java™ private
static data. No other class or subclass (nor instance method in the
same class, if any) can reference COBOL factory data directly. Factory
data is global to all factory methods that the
defines. If you want to make factory data accessible from outside
FACTORY paragraph, define factory attribute (get
or set) methods for doing so.