Implementing EOperations

Category: , , , , By artur
Using EMF and when adding EOperations for generic model operations an empty method body is created. The developer then has several choices on how to fill that empty method. I wonder what would be the most correct. Here is a proposal:

1. Change the JET template for operations gen, interpreting annotation parameters for the EOperation, saying on which class and method the operation can be retrieved. The generated method will delegate the operation to that class:


public Xyx operation(Xyz someArguments) {
   return OperationImplClass.operationImpl(this, someArguments);
}

(OperationImplClass and operationImpl are given by the annotation).


2. Implement the specified external class (Like OperationImplClass).

Is there a simpler way to do it? I am always inclined to avoid any kind of generated code change and this implementation does avoid that. Although this will generate non-compiling code in case the specified class is not created yet. That is a minor issue compared to what is gained in terms of easiness of maintaining all model operations when renaming or deleting. This is only meaningful for really large and complex data models which require constant refactoring.
 

0 comments so far.

Something to say?