Automatic Code Generation

R

Rasmus Fogh

Someone raised the question of automatic code generation a few weeks back.

And yes, we (CCPN) are using automatic Python code generation in a major
way. Basically we are making data models in UML, and using automatic code
generation to make Python APIs, XML I/O etc. (more below). We can be found
at http://www.ccpn.ac.uk/index.html

As a general point, automtic code generation would seem like a good idea
in special cases where:

- a lot of repetitive code can be derived completely from a more compact
or problem-oriented description.
- The problem is large
- You need to keep doing new pieces of code and/or maintain several sets
of synchronized files on top of an evolving problem description
- You avoid hand-modifying the code, either because you can get 100%
automatic generation, or you can 'park' the handcoded modifications where
they are read into the automatic generation process.

Yours,

Rasmus

==========================================================================

In case you are interested, here are some details:

We work on data models for domain-specific data storage and interchange,
making precise data specifications, libraries, XML specifications, etc.
The UML model specifies the classes, attributes and links that describe
the data. We then generate Python classes with properties and access
functions, XML mappings and schemas. We generate Python APIs and XML
storage, and are working on extending to Java and relational databases (in
progress) and C and C++ APIs (planned). All the code generation is done
with Python scripts, of course.

So far, we have:

277 classes and 2006 attributes in the data model

316000 lines of Python (mostly autogenerated) and
527000 lines of HTML documentation (mostly autogenrated)

Better than 98% autogeneration for the API.

Because we need to guarantee that data stored in the model are consistent
and conform to specifications, our Python functions check data type (yes,
we had to), arbitrarily specified constraints, data consistency, data
encapsulation, and supports notifiers so that e.g. GUIs can be notified
when underlying data change.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top