• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Inner Class - UML Question

 
Ricardo Taniguchi
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone!

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
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Regards
Maulin
[ December 02, 2004: Message edited by: Maulin Vasavada ]
 
Sathya Srinivasan
Ranch Hand
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.)
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Isn't a inner class (non-static)a composition relation?

Or an aggregation?

Nick
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nicholas Cheung:

Or an aggregation?

Nick


A non-static inner class dies when the outer top class dies, right?
 
Gian Franco
blacksmith
Ranch Hand
Posts: 979
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

See the following site it gives an indication as to how to represent inner classes.

Cheers,

Gian
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Gian Franco Casula:
Hi,

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
Posts: 379
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic