350 likes | 460 Views
Extension in Domain Specific Code Generation with Ontology Based Aspect Weaving. Meng Tian mt5e09@ecs.soton.ac.uk. Supervisor: Julian Rathke jr2@ecs.soton.ac.uk. Domain Specific Code Generation. Domain Specific Code Generation (DSCG) Model Driven Engineering (MDE)
E N D
Extension in Domain Specific Code Generation with Ontology Based Aspect Weaving Meng Tian mt5e09@ecs.soton.ac.uk Supervisor: Julian Rathke jr2@ecs.soton.ac.uk
Domain Specific Code Generation Domain Specific Code Generation (DSCG) • Model Driven Engineering (MDE) • Raised abstraction level, highly automated • Increased productivity and reliability
Domain Specific Code Generation Domain Specific Code Generation (DSCG) • Model Driven Engineering (MDE) • Raised abstraction level, highly automated • Increased productivity and reliability
Domain Specific Code Generation Domain Specific Code Generation (DSCG) • Model Driven Engineering (MDE) • Raised abstraction level, highly automated • Increased productivity and reliability However, in practice…
Extensions Required e.g. to add logging facilities in the generated code.
Extensions Required e.g. to add logging facilities in the generated code. MDE orthodoxy “model change -> code re-generation”
Extensions Required e.g. to add logging facilities in the generated code. MDE orthodoxy “model change -> code re-generation” Round-trip engineering “code change -> model reverse generation”
Extensions Required e.g. to add logging facilities in the generated code. MDE orthodoxy “model change -> code re-generation” Round-trip engineering “code change -> model reverse generation” What if change not expressible?
Extensions Required e.g. to add logging facilities in the generated code. MDE orthodoxy “model change -> code re-generation” Round-trip engineering “code change -> model reverse generation” What if change not expressible? Or even worse, meta-model change is required
Evolving model-based software Is meta-model change a good thing? Yes. Now my modelling language is more expressive and powerful. • Is that still abstraction? • Is that cost effective? • Compatible problems?
Evolving model-based software Is meta-model change a good thing? Yes. Now my modelling language is more expressive and powerful. • Is that still abstraction? • Is that cost effective? • Compatible problems?
Extensions Required e.g. to add logging facilities in the generated code. MDE orthodoxy “model change -> code re-generation” Round-trip engineering “code change -> model reverse generation” What if M’=M
Where is the problem? Modification CANNOT be reflected in the model.
Where is the problem? Modification CANNOT be reflected in the model. Causes: • Model and code are both maintained explicitly as core products. • Forceful synchronization of artefacts of two different abstraction level is unnecessary and may break abstraction levels.
Where is the problem? Modification CANNOT be reflected in the model. Causes: • Model and code are both maintained explicitly as core products. • Forceful synchronization of artefacts of two different abstraction level is unnecessary and may break abstraction levels.
What makes the magic mapping? The code generator!
What makes the magic mapping? The code generator!
What makes the magic mapping? The code generator!
Our approach • No “model-code” synchronization. • An intermediate layer – aspect, between model and code, in which modification can be expressed flexibly. • As the aspect languages are built based on the domain ontology, we call them Ontology Based Aspect languages (OBALs)
Test with ANTLR Parser Generator Production rule in ANTLR grammar Extension for program synthesis functionalities in ANTLR grammar can be difficult, sometimes even impractical.
Test with ANTLR Parser Generator Production rule in ANTLR grammar Extension for program synthesis functionalities in ANTLR grammar can be difficult, sometimes even impractical.
Test with ANTLR Parser Generator Production rule in ANTLR grammar Extension for program synthesis functionalities in ANTLR grammar can be difficult, sometimes even impractical.
Test with ANTLR Parser Generator Count how many if-only statements in a Java program, and how many equality check involved.
Test with ANTLR Parser Generator Begin_Parse_Rule_statement_Alternative_1(); End_Parse_Rule_statement_Alternative_1(); Begin_Match_Token_ELSE(); End_Match_Token_ELSE();
Test with ANTLR Parser Generator Begin_Parse_Rule_statement_Alternative_1(); End_Parse_Rule_statement_Alternative_1(); Begin_Match_Token_ELSE(); End_Match_Token_ELSE();
Test with ANTLR Parser Generator Begin_Parse_Rule_statement_Alternative_1(); End_Parse_Rule_statement_Alternative_1(); Begin_Match_Token_ELSE(); End_Match_Token_ELSE();
Evaluation Benefits • It solves the “model non-reflectable” extension problem. • It makes the generator extensible, instead of simply extending it. • There is no model compatible problem. • It allows modification to be described in a flexible way. • The aspect based extension process can be fully automated. Limitations • Knowledge of the code generator is required. • Maintenance of ontology tracing information
Conclusions • We introduced a new approach for extending the generated code in model-based software development, i.e. via ontology-based aspect. • Under certain assumptions, our approach can generate the aspect language over the ontology model, and produce the corresponding weaver provided ontology tracing information.
Future Work • Standardize the ontology definition schema, i.e. meta meta model. • Supporting restrictions in domain ontology. E.g., access control, conflict prevention. E.g., OCL based solution.