I was wondering if UML has any special notation or stereotype for Inner Classes. Has anyone seen this before?
I'd also like to know if there's also someway to describe final methods and attributes in a class diagram.
Is there any place in OMG's site that I can search for these questions?
Thanks!
Ricardo
Maulin Vasavada
Ranch Hand
Joined: Nov 04, 2001
Posts: 1865
posted
0
Hi Ricardo,
In my opinion, UML should not cover inner classes specifically. Inner classes are specific way in Java to do things...
Even if UML wants to include this inner class notion, they might have to think extensively enough to derive general meaning of inner classes (that spans across infinite languages we have) and then probably they can come up with something "directly supported" by UML notation for inner classes.
I am not sure if there exist anything to mark final methods and all. That is probably again Java specific (can we do something like that in C++? I am not sure...its long I did C++)...
In essence, UML should not end up having notations that make sense to few languages...it is to present classes and their relations and other aspect of design rather than "implementation specific" decisions.
Final attributes are usually denoted using "underline" in UML. So, final (or constant) variables will normally be underlined. I guess this notation can be stretched to methods also, although I don't know if tools like Rational support it (maybe its Java extension would).
Originally posted by Sathya Srinivasan: Not sure about inner classes.
Final attributes are usually denoted using "underline" in UML. So, final (or constant) variables will normally be underlined. I guess this notation can be stretched to methods also, although I don't know if tools like Rational support it (maybe its Java extension would).
No, underline means *static*, not final! (And it can be used for methods, too.)
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
posted
0
UML doesn't have a standard notation for inner classes.
There is a custom notation mentioned in "UML for Java Programmers" by Robert C. Martin, but I'm not sure wether I'd use it. Most often it's a detail I wouldn't care to depict more explicitely than by the class' name.
Originally posted by Ilja Preuss: UML doesn't have a standard notation for inner classes.
There is a custom notation mentioned in "UML for Java Programmers" by Robert C. Martin, but I'm not sure wether I'd use it. Most often it's a detail I wouldn't care to depict more explicitely than by the class' name.
Isn't a inner class (non-static)a composition relation?
See the following site it gives an indication as to how to represent inner classes.
Cheers,
Gian
This was the representation Ilja was talking about.
Sathya Srinivasan
Ranch Hand
Joined: Jan 29, 2002
Posts: 379
posted
0
Originally posted by Ilja Preuss:
No, underline means *static*, not final! (And it can be used for methods, too.)
Oops. Thanks for the correction! Well, since italics (for abstract) and underline (for static) are already taken, the only thing I can think of is bold font for final!!
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
posted
0
Originally posted by Sathya Srinivasan: Oops. Thanks for the correction! Well, since italics (for abstract) and underline (for static) are already taken, the only thing I can think of is bold font for final!!
That puts a little bit too much emphasis on such a rather unimportant modifier, doesn't it?
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
posted
0
Originally posted by Pradeep Bhat:
This was the representation Ilja was talking about.
Well, yes - though I didn't know about this site, nor that it was an official element of UML (which the page seems to indicate). Spooky...
Ricardo Taniguchi
Greenhorn
Joined: Jun 13, 2003
Posts: 10
posted
0
Actually it's very strange for me to declare inner classes as a kind of composition.
As a matter of fact, it has access to private attributes and methods, and therefore couldn't be represented as an external class.
Just wondering.
Anyway, I'd like to thank everyone for clarifications!
Ricardo
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
posted
0
Originally posted by Pradeep Bhat:
A non-static inner class dies when the outer top class dies, right?
Well, it's rather the other way around: the outer instance cannot be garbage collected before the inner instances get collected, too - because the inner instances hold an implicite reference to the outer one.
That *could* be seen as a composition relationship, but which way it points mainly depends on how you use the classes, as far as I can tell.
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
posted
0
Originally posted by Ricardo Taniguchi: As a matter of fact, it has access to private attributes and methods, and therefore couldn't be represented as an external class.
Actually it will get compiled to an "external" top-level class, because the JVM doesn't know about inner classes. The compiler uses some tricks to implement kinda C++-like friend relation between the classes.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.