Book a Demo

Author Topic: Howto model an exception of an operation?  (Read 3183 times)

Andreas_G

  • EA User
  • **
  • Posts: 125
  • Karma: +0/-0
  • And that's the way the cookie crumbles.
    • View Profile
Howto model an exception of an operation?
« on: June 17, 2004, 11:43:19 pm »
Hi,

did anybody know if there is a way to model an exception of an operation in UML and EA?

I searched in the operations dialog. But can't find this feature.
bye
Andreas

thomaskilian

  • Guest
Re: Howto model an exception of an operation?
« Reply #1 on: June 17, 2004, 11:52:22 pm »
What do you think of a state diagram?

Andreas_G

  • EA User
  • **
  • Posts: 125
  • Karma: +0/-0
  • And that's the way the cookie crumbles.
    • View Profile
Re: Howto model an exception of an operation?
« Reply #2 on: June 18, 2004, 12:25:01 am »
hmmm... I hoped it is possilbe in class diagram.

The only thing I want to show is "this operation has the posibilty to throw an exeption of an special type".

I need it also for code generation. And that's not possible with state diagram.
bye
Andreas

thomaskilian

  • Guest
Re: Howto model an exception of an operation?
« Reply #3 on: June 18, 2004, 02:52:09 am »
2nd guess: stereotyped method?

angel-o-sphere

  • EA User
  • **
  • Posts: 112
  • Karma: +0/-0
    • View Profile
Re: Howto model an exception of an operation?
« Reply #4 on: June 18, 2004, 03:15:23 am »
Visually you do it liek this:

on a class diagram you draw a dependency from the class containing the method to the class which is thrown as exception. Use a stereotype <<exception>> or <<throws>>. However with that you can not express which method throws the exception.

For code generation you use a tagged value at the method. Tag is "throws" and the value is a ',' seperated list of full quallified class names.

EA does not expand that by default (as far as I know), so you have to modify the code generation template (might lead to problems in round trip engineering).

To extend the code generation I would start with using a marker stereotype, like <<except>> or something on the method. EA supports to "overwrite" the generation templates on a stereotype base. That means you get a new script for exporting methods for that stereotype. Those you can edit without interfering with the standard export template.

BTW: the UML standard suggests to sue the tagged value approach .... usualy the tag name is derived from the keyword used in the programming language (throws in Java) but AFAIK "throws" is also the standard tag name.

Hope that helps,
   angel'o'sphere
« Last Edit: June 18, 2004, 03:17:19 am by aos »

Andreas_G

  • EA User
  • **
  • Posts: 125
  • Karma: +0/-0
  • And that's the way the cookie crumbles.
    • View Profile
Re: Howto model an exception of an operation?
« Reply #5 on: June 18, 2004, 04:43:10 am »
Hi Thomas, hi angle'o'sphere,

thanks for your fast help.
My hope about an easy solution is gone away  ;)

But the idea with the tags from angle'o'sphere sounds good.
sadly, I have to become more familiar with this generation templates first.

bye
Andreas
bye
Andreas