Book a Demo

Author Topic: Modifying code templates  (Read 2853 times)

rickaby

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Modifying code templates
« on: July 08, 2005, 05:48:29 am »
We have a requirement to add a copyright declaration to every source code module.  I was thinking of doing this for UML generated code by modifying the 'File' code template to add a copyright line.  This raises a number of questions:

1.  The help states that overridden code templates are stored in the .EAP file.  Presumably that means in the model?  (We are using SQL server repository).

2.  What happens if the modified code template is later updated by Sparx when EA is upgraded?  Do you get a warning message at any stage?  Or is it my responsibility to trawl through all of the release notes?

3.  Is there any way of 'inheriting' the original code template within my modified template (so it would always have the most recent one)?

4.  The copyright needs the year to be included.  Is there a way of picking up the current year (at code generation time) or do I need to modify the template every January to keep it up to date?

5.  Is there any easy way of exporting changes to existing models (e.g. when updating the date at the start of a year)?

...or is there a better way of doing this without modifying the code templates?
Chris Rickaby

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Modifying code templates
« Reply #1 on: July 10, 2005, 03:55:43 pm »
1. Yes, that's right.
2. Your changes always overwrite the default templates that we provide.  You don't get a warning message that we have updated templates, but the release notes specify clearly when a template has been changed.  For example, the following appears in the release notes for build 765.
Quote
Code Template Updates:
 - Added support for partial classes to the C# Class Declaration template.

3. Unfortunately no.  If you want to get our changes then you will have to manually update your templates.  On the plus side.  I can remember only one file template that we have updated in the last 1.5 years.
4. The code templates have a macro %eaDateTime%, and also provide enough string processing macros to extract the year from it. (http://sparxsystems.com.au/EAUserGuide/index.html?functionmacros.htm)
5. Look at Tools | Export Reference Data.  Any code template changes will be listed in there. (eg. C++_Code_Template)

Simon

rickaby

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Modifying code templates
« Reply #2 on: July 11, 2005, 02:20:14 am »
Many thanks for your  help.   :)
Chris Rickaby