Book a Demo

Author Topic: Define an operation's exceptions  (Read 4611 times)

du-it

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Define an operation's exceptions
« on: October 12, 2005, 06:57:21 am »
I'm a newbie to enterprise Architect.
How can I define Exceptions thrown by an operation (target language is Java)?

Thanks,

Dirk

TrtnJohn

  • EA User
  • **
  • Posts: 176
  • Karma: +0/-0
    • View Profile
Re: Define an operation's exceptions
« Reply #1 on: October 12, 2005, 01:43:11 pm »
Exceptions thrown by a method is more a behavioral element than structural so it would not be shown in your class diagram.  You can show every exception that a class can generate in a class diagram.  But, that typically gets too messy.  For each method you can specify Post and Pre conditions.  This is where I typically document exceptions for each method.  For example the DeleteFile(Filename) method will have a precondition that "File exists".  In the notes for this condition you can add "Throws FileNotFound exception if file does not exist".    Also, if you draw behavior diagrams such as sequence diagrams you would show each exception thrown there.
« Last Edit: October 12, 2005, 01:44:02 pm by TrtnJohn »

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Define an operation's exceptions
« Reply #2 on: October 12, 2005, 03:12:48 pm »
If you're wanting to specify the exceptions for code engineering, add a tag "throws" to the method with the value of any exceptions that the method throws.

To see an example of this, try reverse engineering a java method that contains a throws specification.

du-it

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Define an operation's exceptions
« Reply #3 on: October 13, 2005, 12:23:59 am »
Thanks to both of you.

In the meantime I defined a tag named "throws" since I found it somewhere in a documentation/tutorial.
I will additionally apply your suggestion, TrtnJohn. I think it's good manner to define pre and post conditions.

Thank you,

Dirk