|Re: [Acceleo 3] Protected Area [message #655150 is a reply to message #655097]
||Fri, 18 February 2011 13:57
| Stephane Begaudeau
Registered: April 2010
Location: Nantes (France)
So let me explain protected areas:
1- you generate some code, then you modify that generated code and you launch the generation once again -> your modification in the generated files are lost
2- you generate some code with a protected area (with an unique identifier -> [protected ('myIdentifier')] ... [/protected] in a given file), you modify your generated code inside of the protected area and outside of the protected area, you launch the generation once again -> the code modified in the generated file outside of the protected area is lost, the code modify inside of the protected area is still there.
Since with a code generation project, you will one day have to modify the generated code. Even when you think that you won't, you will because you will be lazy / late / anything else
The protected area allow you to prepare some parts of the generated code for modifications. You can predict where those modifications should appear and where your generator will support those modifications.
If you create an UML to Java generator, you want to create a protected area between the last attribute and the constructor so that you can modify without risk the generated code to add a new attributes and you want to create a protected area after all your generated method to give the user the opportunity to add new methods.
For more information on protected area, you can find here a video that I've realized for the conference Topcased Days, during the "part 7" I show how protected areas work (start at 7min 25s in the video part7).
Stephane Begaudeau, Obeo
Acceleo wiki: http://wiki.eclipse.org/Acceleo
Blogs: http://stephanebegaudeau.tumblr.com & http://sbegaudeau.tumblr.com
[Updated on: Fri, 18 February 2011 13:58]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.01886 seconds