2 Generator in Action
The generator produces a Java class for each product, one ?¬?le per speci?¬?cation. If the
product speci?¬?cation was more complex, having multiple separate diagrams, all the
diagrams in the hierarchy were used to create the class ?¬?le. The class implements a
product creation method that adds all insurance-speci?¬?c details from the model to the
product speci?¬?cation. In other words, it instantiates them as Java objects on the
platform based on a prede?¬?ned metamodel implementation.
From the product speci?¬?cation described in Fig. 6.7, the generator produces 962
lines of Java code. In production use, the average size of generated code was 2000
lines per insurance product and the largest was over 4000 lines. Next let??™s examine
the generator by looking at the generated code.We will only inspect some parts here:
the main product creation code, code produced from a modeling object that is a
domain-speci?¬?c concept part of the insurance product, and code created based on
the connections the domain concepts treated as objects in the model have. The
sample code is taken from a generated insurance speci?¬?cation, 2188 lines of code in
total.
GENERATOR FOR JAVA 135
Listing 6.2 shows part of the generated code. Numbers at the beginning of the
lines refer to the lines of the generated ?¬?le.
Pages:
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267