This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes OO, Patterns, UML and Refactoring and the fly likes Notations for UML interfaces Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Notations for UML interfaces" Watch "Notations for UML interfaces" New topic
Author

Notations for UML interfaces

James Chegwidden
Author
Ranch Hand

Joined: Oct 06, 2002
Posts: 201
I have seen in different books different notations to represent Interfaces in UML class diagrams. Two authors also told me the same. I have tried various sources but which is more common:

<<interface>>
Interface Name
All methods in italics

or

Interface Name
All methods in italics

or
<<interface>>
Inteface name
All methods regular font (no italics)

Input appreciated

JC


Author and Instructor, my book
B.Sathish
Ranch Hand

Joined: Aug 18, 2005
Posts: 372
An interface is considered to be a stereotype in UML. A stereotype is something that is not a core UML construct but similar to one. Thus an interface is a stereotype of a class in UML. Stereotypes are represented by guillemets << >>

<<interface>>
Interface Name
Operations

You could also use the {abstract} constraint along with / in place of italics.

Hope this clarifies.
B.Sathish
Ranch Hand

Joined: Aug 18, 2005
Posts: 372
Sorry I meant << >> and not < >
Scott Ambler
author
Ranch Hand

Joined: Dec 12, 2003
Posts: 608
The abstract constraint would be incorrect.

To model the interface itself the notation would be:
------------------------------
| <<Interface>> |
| Inteface name |
|----------------------------|
| Static attributes (if any) |
|-----------------------------
| Methods |
------------------------------

In the UML the stereotype is placed in the wrong position, IMHO. It should actually appear below the interface name, not above it, because the name is more important than the stereotype.

I have examples of modeling interfaces at http://www.agilemodeling.com/style/interface.htm if you're interested.

- Scott


<a href="http://www-306.ibm.com/software/rational/bios/ambler.html" target="_blank" rel="nofollow">Scott W. Ambler</a><br />Practice Leader Agile Development, IBM Rational<br /> <br />Now available: <a href="http://www.ambysoft.com/books/refactoringDatabases.html" target="_blank" rel="nofollow">Refactoring Databases: Evolutionary Database Design</a>
James Chegwidden
Author
Ranch Hand

Joined: Oct 06, 2002
Posts: 201
Scott, I saw your site. is the interfaces with the guillmets. Are the methods in italics (since with interfaces they are automatically abstract) I cannot tell from you written diagram.

Also, what about the convention of putting the letter I with the interface name- IClassName.

JC
Dave Wood
bronco
Ranch Hand

Joined: Aug 02, 2004
Posts: 161
While it would seem logical (IMHO) for the operation names to be in italics, they are not supposed to be.


Co-Author of <a href="http://www.oreilly.com/catalog/jswing2" target="_blank" rel="nofollow">Java Swing</a><br />Co-Creator of <a href="http://www.sun.com/training/catalog/courses/CX-310-055.xml" target="_blank" rel="nofollow">SCJP 5.0</a> and <a href="http://www.sun.com/training/certification/java/associate_beta.xml" target="_blank" rel="nofollow">SCJA</a> exams
Reid M. Pinchback
Ranch Hand

Joined: Jan 25, 2002
Posts: 775
Originally posted by Scott Ambler:
In the UML the stereotype is placed in the wrong position, IMHO. It should actually appear below the interface name, not above it, because the name is more important than the stereotype.


You can't help but wonder if the stereotypical (sic) placement of the stereotype has more to do with some VB GUI code written by a summer intern at Rational once upon a time than for any more rational (sic x 2) reason.


Reid - SCJP2 (April 2002)
Scott Ambler
author
Ranch Hand

Joined: Dec 12, 2003
Posts: 608
Italics: No.

The I naming convention is common in the Microsoft world, but in Java generally not.


You can't help but wonder if the stereotypical (sic) placement of the stereotype has more to do with some VB GUI code written by a summer intern at Rational once upon a time than for any more rational (sic x 2) reason.


Perhaps. I think that it's because:
1. The OMG contributors didn't have a handle on basic HCI stuff.
2. They were so excited about the concept of stereotypes at the time they thought that everyone else would be, so they put them first.

- Scott
James Chegwidden
Author
Ranch Hand

Joined: Oct 06, 2002
Posts: 201
Scott, Is your book published through a major texbook publisher. I may adopt it for my Java C++ online course in the fall. Will have to get an exam copy..

JC
Scott Ambler
author
Ranch Hand

Joined: Dec 12, 2003
Posts: 608
The Object Primer 3rd Ed is likely your best bet, and it's published by Cambridge University Press (CUP). My other books are published by various publishers, including CUP, Wiley, and Addison Wesley.

- Scott
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Notations for UML interfaces
 
Similar Threads
ePractice Exam Question (UML)
FREE Mock exam on SCJA
UML question regarding abstract and interface classes
Head First OO Book- Class Diagram Question
SCJA Mock Exam, Answer Clarification Please