Book a Demo

Author Topic: CodeGen: Extra Var created for  Abstract Property  (Read 2857 times)

eAndy

  • EA User
  • **
  • Posts: 30
  • Karma: +0/-0
    • View Profile
CodeGen: Extra Var created for  Abstract Property
« on: March 24, 2007, 05:08:33 am »
Code generating in C#

Create an abstract readonly property.

When I code gen it still creates the private variable

private float _NPV;  // this shouldn't be created!!
public abstract float NPV
{

get;
}

I tried modifying the code template as shown in the red below but it doesn't work. What am I missing?

%if attStereotype == "property" and opAbstract != "T"%
\n{\npop\t//read property\n\tget{;}\n\t//write property\n\tset{;}\n}
%endTemplate%
« Last Edit: March 24, 2007, 05:12:14 am by eAndy »

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: CodeGen: Extra Var created for  Abstract
« Reply #1 on: March 24, 2007, 05:40:57 am »
{cause} You are possibly creating it from a defined attribute?  
{solution} Create it from a class operation stereotyped as property.

{contraindications}
e.g. if you say the class has an atribute "marshmallows" and create a property from that attribute then it doesn't matter whether you define thw subsequent property as abstract, isQuery, const or any other damn UML qualifier, that affects the property not the attribute.

e.g.(other) create an attribute "pumpkins", then create a property "Fish" from it, then create a property "FlyingSaucers" from it. Change the properties as you will.  Note the attribute still exists.

e.g.(final) create an attribute "billycart", make it a property called "Esmerelda", then make the property derived.  What is it supposed to do? Delete the attribute?

Code: [Select]

coerce(C#.property <> EA.property) = true;
coerce(EA.property <> UML.property) = true;
if !( UML.property == Reality.property) {
   System.Console.Writeln("Damned if I know")
  }
else {
  System.Console.Writeln("Damned if I know!")
}



keep tryin'


bruce

p.s. Whhat happened to my spell cjecker?????
« Last Edit: March 24, 2007, 05:45:29 am by sargasso »
"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

eAndy

  • EA User
  • **
  • Posts: 30
  • Karma: +0/-0
    • View Profile
Re: CodeGen: Extra Var created for  Abstract Prope
« Reply #2 on: March 27, 2007, 01:29:31 pm »
Ah, yes.

I was creating an attribute and then marking it as a property.

I went back and
1. created an operation
2. set the stereotype to "property"
3. marked it as abstract
4. gen'd code
5. Viola! exactly what I expected, duh!

Thanks much
eAndy