100 likes | 285 Views
ReMoDeL. Code Generators. Background. Model-Driven Engineering (MDE) Software systems will be designed at a high level of abstraction, in terms of models. Eg : OMG’s Model-Driven Architecture (MDA) Aims to use UML, and QVT technologies L arge and heavy; no complete implementations ReMoDeL
E N D
ReMoDeL Code Generators
Background • Model-Driven Engineering (MDE) • Software systems will be designed at a high level of abstraction, in terms of models. • Eg: OMG’s Model-Driven Architecture (MDA) • Aims to use UML, and QVT technologies • Large and heavy; no complete implementations • ReMoDeL • Reusable Model Design Languages • Alternative lightweight approach • Aims to use XML models and transformations • Existing proof-of-concept
ReMoDeL Goals • PIY: Program-it-yourself • End-users will be able to construct systems in terms of familiar models (domain-specific) • SHC: Scrap-heap challenge • System evolution will be at the model-level, by cannibalising existing models (agility) • SVT: Self-verify and test • Systems generated automatically from models, correct-by-construction, self-testing
Model Languages • Multi-level approach • Transform high-level model of system to code • Use models as intermediate representations • High-level languages • Eg: ReMoDeL DBQ: represents records, associations, multiplicities, query expressions • Low-level languages • Eg: ReMoDeL OOP: represents classes, interfaces, primitive types, methods, fields • XML-based • All languages defined in XML
Code Generators • Darwin Project Scope • Start with ReMoDeL OOP • Translate into actual OO code • Use existing Generator framework • Darwin Project Goals • Develop a set of OOP models of systems • Evaluate existing Java, C++ generators • Develop translators for C#, Eiffel, Delphi • Evaluate these translators on the same models • Is the OOP model adequate?
Generator Framework ProgramGenerator PackageGenerator ClassGenerator MemberGenerator CodeGenerator
Example OOP <?xml version="1.0" encoding="UTF-8" ?> <Package name="People" model="OOP" location="example.people"> <Class name="Person"> <Employ type="String" from="Core" location="lib.core" /> <Field name="forename" type="String" visible="private" /> <Field name="surname" type="String" visible="private" /> <Field name="gender" type="String" visible="private" /> <Creator name="make" type="Person" visible="public"> <Variable name="forename" type="String" /> <Variable name="surname" type="String" /> <Variable name="gender" type="String" /> <!-- body of creator omitted --> </Creator> <!-- further methods omitted --> </Class> </Package>
Example in Java package example.people; import lib.core.Object; import lib.core.String; public class Person extends Object { private String forename; private String surname; private String gender; public Person (String forename, String surname, String gender) { // Body of constructor omitted } // Further methods omitted }
Example in C++ (.h) #ifndefPERSON_H #define PERSON_H #include "..\..\lib\core\Object.h“ namespace People { using Core::Object; class String; class Person : public Object { private: Ref<String> my_forename; Ref<String> my_surname; Ref<String> my_gender; public: Person (Ref<String> forename, Ref<String> surname, Ref<String> gender); // Further methods omitted }; } // People #endif
Challenges • Understand ReMoDeL OOP • Download and review OOP specification doc • http://www.dcs.shef.ac.uk/~ajhs/remodel/ • Install target language compilers • Eiffel, C#, Delphi – get these to work? • Understand Generator framework • JDOM framework for XML • Visitor design pattern in Java • Execute generated systems • On target language compilers • Using core target libraries