aspose file tools*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Inner Class - UML Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Inner Class - UML Question" Watch "Inner Class - UML Question" New topic
Author

Inner Class - UML Question

Ricardo Taniguchi
Greenhorn

Joined: Jun 13, 2003
Posts: 10
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

Joined: Nov 04, 2001
Posts: 1871
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

Joined: Jan 29, 2002
Posts: 379
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).


Cheers, Sathya Srinivasan - SCJP 1.2, SCWCD 1.2, SCMAD 1.0
Co-Author of Whizlabs SCMAD Certification Exam Simulator and SCMAD Exam Guide Book
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
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
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

Joined: Feb 27, 2002
Posts: 8919

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?


Groovy
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
Isn't a inner class (non-static)a composition relation?

Or an aggregation?

Nick


SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

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

Joined: Dec 16, 2003
Posts: 977
Hi,

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

Cheers,

Gian


"Eppur si muove!"
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

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

Joined: Jan 29, 2002
Posts: 379
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
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
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
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
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
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.
 
 
subject: Inner Class - UML Question