Automatic Code Generation
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
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.
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.
Dr. Rasmus H. Fogh Email: firstname.lastname@example.org
Dept. of Biochemistry, University of Cambridge,
80 Tennis Court Road, Cambridge CB2 1GA, UK. FAX (01223)766002
|All times are GMT. The time now is 05:31 AM.|
Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.