When I talk about code generation from UML models at conferences – one question will always appear from the audience!
Can I do full round-trip between code and model?
My Answer is NO! Most modelling tools support Round-Trip Engineering for Class Stubs in a decent way – still you need to be careful no to screw your model or code. But as of my knowledge “full” round-trip of behaviour models is a “myth”.
And if you just use modelling techniques to generate your stubs it is not what we typically would suggest to our clients.
To get the most out of it you need to do forward only – only this way you can make sure your documentation matches your code! See also: Article
But we also believe in starting with legacy code and projects! Therefor it is absolutely ok to reverse engineer code that you will not touch with the model and reference it from the model. We have a little visual to illustrate that:
Another exception that we think makes sense is to synchronize method/function content into the model before regenerating the source files from the model. With this optional capability you will have the best of both worlds.