Book a Demo

Author Topic: method variables  (Read 3508 times)

mtanzer

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
method variables
« on: February 14, 2006, 06:40:39 am »
I am new to using UML and have started trying to model some very basic structures. One thing I am trying to figure out is if there is a way to model variables declared inside a method. Can anyone help a newbie?

Mark

Mitch

  • EA User
  • **
  • Posts: 23
  • Karma: +0/-0
    • View Profile
Re: method variables
« Reply #1 on: February 14, 2006, 08:01:21 am »
Varaibles inside a method, or inside a class?

From my perspective, variables inside a method are a bit too much detail for a UML diagram.

Variables inside a class can me modeled as Class Attributes, or through composition (i.e an association with the black diamond on one end).

Mitch

mtanzer

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: method variables
« Reply #2 on: February 14, 2006, 08:06:23 am »
I was talking about inside a method. I have been able to set up class attributes without any problems. My search for method variables with UML has turned up nothing so far, so maybe I am trying to add too much detail. ALthough, as I understand, it is possible to generate code from models. Does this mean stub code is really the best you can get out of a UML model?

Mark

Mitch

  • EA User
  • **
  • Posts: 23
  • Karma: +0/-0
    • View Profile
Re: method variables
« Reply #3 on: February 14, 2006, 08:24:02 am »
We generate method stubs and then fill in the stubs. You should try it and then experiment with reverse engineering (called synchronizing in EA). When you reverse engineer, EA doesn't mess with the code you've added inside the method.

For example you can add a method via code, then reverse engineer the code to EA. The new method will be added to your class in EA.

There's also a field in the operations dialog where you can add addtional code. I don't use it because I'm more comfortable writing code in the code editor.

For the most part the forward and reverse engineering work well, except for changing the name of a variable. Then, EA can't keep track of the old variable, so you the code ends up with the old variable and the new variable.

Changing the name of a class can really wreck havoc.

At first, I ran a lot of diffs after generating code.

Good luck,

Mitch

mtanzer

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: method variables
« Reply #4 on: February 14, 2006, 08:40:00 am »
Thanks Mitch, I'll give it try.

Mark

SF_lt

  • EA User
  • **
  • Posts: 216
  • Karma: +1/-0
  • The Truth Is Out There
    • View Profile
Re: method variables
« Reply #5 on: February 14, 2006, 11:02:02 am »
there is a way to model this: use dependency with stereotype <<variable>> or <<localVariable>> or whatever you like.

Another way would be to define your own tags - affraid, this may require profile.

To generate code by using dependencies or tags will require changes in a code generation templates. However, this is doible, but currently where is no standard on this ;)
registertm everything to SparX