Book a Demo

Author Topic: code engineering: attributes  (Read 2996 times)

rabra

  • EA User
  • **
  • Posts: 50
  • Karma: +0/-0
    • View Profile
code engineering: attributes
« on: November 21, 2006, 06:18:26 am »
Hallo,

when I transform 2 1:n - associated class to a model and have set the default attrib to 'm_$LinkClass', in the generated code, some attributes have got the prefix 'm_'. But there is also generated an attribute with the original name. How can I avoid that except from deleting them from the code manually or manually rename all my attributes?


Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: code engineering: attributes
« Reply #1 on: November 21, 2006, 01:07:46 pm »
I'm not completely sure of the situation you're describing.

My first recommendation would be to enable to option for removing code elements not found in the model.  (Tools | Options | Attribute/Operations | On forward synch prompt to delete code features not in model)  If this doesn't prompt you to remove those attributes, then they are described in your model somewhere.

This behavior is described at http://sparxsystems.com.au/EAUserGuide/index.html?cgo_synchcode.htm.


Secondly, it's possible to set this option on a per-class basis, so some classes may be using a different value of this option.  Please see http://www.sparxsystems.com/EAUserGuide/index.html?resetoptions.htm for more information about this.

rabra

  • EA User
  • **
  • Posts: 50
  • Karma: +0/-0
    • View Profile
Re: code engineering: attributes
« Reply #2 on: November 22, 2006, 05:53:13 am »
Your hints were interesting as I did not know these features yet.
But my problem was a little different.

A class in my model may have an attribute 'ClassName xyz' that is an 1:n collection. As default collection class I have defined ArrayList. The option 'Auto generate role names when creating code' in object options is on. Default name for associated attrib is 'm_$LinkClass'.

When I now generate code, two attributes appear:
1. private ClassName xyz;
2. private ArrayList m_xyz;

The first one is the one described in the model but does not consider the collection. The second one is ok.

My question is how I can avoid generating the first one OR delete it (except manually).
Because if I set the option 'Auto generate role names when creating code' off and generate a second time I am asked if I want to delete the second one, not the first one.
« Last Edit: November 22, 2006, 06:34:47 am by rabra »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: code engineering: attributes
« Reply #3 on: November 22, 2006, 01:07:21 pm »
What I believe may be happening is that in addition to the attribute you have described, you also have a  1:n association from that class to xyz.

The model attribute you have described will be generating the first code attribute, this will not use the collection class to generate.  Collection classes are only used for associations.  It's also not going to change the name of the attribute generated.

Your second attribute will be generated from the connector using the default collection class and the option for how to name unnamed attributes from associations.

If you don't want the first one in your model, delete the attribute from the model or change it to match the association.