dcsimg
What are the plans to represent a Java throws signature element in a UML method signature?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   James_Violette
Posted On:   Thursday, June 21, 2001 10:50 AM

How do I represent a Java throws signature element in a UML method signature? Are there plans to add this to the UML specification? For example the Java interface, public interface MyInterface { public Object myMethod(Object myParam) throws MyException; } translates to UML: -------------------------------------- | < > | | MyInterface | -------------------------------------- | +myMethod(myParam:Object) : Object | -------------------------------------- The throws clause is lost completely. One suggestion was to include all exceptions   More>>

How do I represent a Java throws signature element in a UML method signature?

Are there plans to add this to the UML specification?

For example the Java interface,

			
public interface MyInterface
{
public Object myMethod(Object myParam) throws MyException;
}



translates to UML:

			
--------------------------------------
| < > |
| MyInterface |
--------------------------------------
| +myMethod(myParam:Object) : Object |
--------------------------------------



The throws clause is lost completely. One suggestion was to include all exceptions thrown by a class in its own Class diagram box, but that drops the fact that exceptions are thrown by specific methods, rather than a class.    <<Less

Re: What are the plans to represent a Java throws signature element in a UML method signature?

Posted By:   jim_conallen  
Posted On:   Friday, June 22, 2001 06:42 PM

As far as official plans, you'll have to get word directly from someone on the UML 2.0 committee at the OMG - of which I am not (said with a sign of relief :-)



Looking at Grady's book (UML User's Guide pg 285) I see that exceptions are
modeled as classes (because in Java they really are defined by classes).
What you are really looking for is a way to visually represent a particular
operation in an arbitrary class throwing that exception. In the user's guide it
says that a <> stereotyped dependency is drawn directly from
the operation in the class compartment to a <>
stereotyped class. Note that the depenency is drawn from the operation
itself, not the boundary of the class (really hard to see in this ascii
rendering i know).



-------------------------------------------
| <> |
| MyInterface |
| --------------------------------------- | |-----------------|
| | <> | <> |
| +myMethod(myParam:Object) : Object - - -+- - - - - - - - - >| MyException |
| | -------------------
-------------------------------------------


On a side note, I was unable to find any references to the modeling of exceptions
in the UML specification from the OMG. So this particular use of the stereotypes and
notation might not be cleared with the OMG committee so far.



Unfortunately I don't know of any UML modeling tool (real tools not just
free form drawing programs) that allow you to draw dependencies directly from an
operation. So I think that the practical way to model especially important
exception throwing is with a dependency from the class to the exception class, but
with either tag values of the operations that throw it, or by naming the dependency with
the list of operations that throw the exception.

About | Sitemap | Contact