The future is what you make of it
Trey Spiva's Weblog
Archives
« November 2009
SunMonTueWedThuFriSat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
     
       
Today
Click me to subscribe
Search

Blogroll
Links
 

Today's Page Hits: 29

Tuesday Mar 13, 2007
Early Result for the UML Survey

Today is the last day to fill out the survey for the Netbeans UML module.  So, I thought I would share some early results of the survey.  As of Sunday there have been 67 responses. if you have not already taken the survey, please take some time to give us your opinion.

The current results are as followings:

Stability: Excellent 34%, Somewhat 60%, Not Stable 6%
How Often Used: Often 42%, Somewhat 45%, Never 13%
Usability: Excellent 36%, Somewhat 54%, Not Usable 10%
Performance: Excellent 42%, Somewhat 54%, Not Adequate 4%
Documentation: Excellent 46%, Somewhat 52%, Not Adequate 1%

The interesting thing to note, is that almost everyone that said the tool is not usable said it was because it does not support generics.  I would like to hear more information about how UML does not support generics.  The reverse engineering and code generation does have generic support, but perhaps there are areas that are not covered so well.  I know of one important issue that was fixed in the last couple of days.  I think that this issues will make a big difference.  Please let me know what you think.

Types of Users
Design/Architect: 84%
Code Generation: 66%
Reverse Engineering: 75%

Diagrams Used
Activity: 34%
Class: 93%
Collaboration: 19%
Component: 30%
Deployment: 19%
Sequence: 58%
State: 33%
Use Case: 64%

Modeling Activities
Report Generation: 40%
Reverse Engineering: 66%
Code Generation: 69%
Design Patterns: 40%
Requirements Gathering:  36%

Posted at 10:01AM Mar 13, 2007 by Trey Spiva in UML  | 

Wednesday Mar 07, 2007
Representing Generics in UML

Generics was a new feature in Java 5.  This is not new, because Java 5 has been out for a long time now.  Now that NetBeans has UML support, we are getting a lot of questions about UML support of Generics.  I will make an attempt to demonstrate how UML can represent generics.

In UML every classifier can have template parameters.  Classifiers are things like Class, Interfaces, and even Use Cases.  To use a template you have to create an instance of the template.  The instance of a template is a new type.  Creating an instance of a template is similar to extending a class.  This is not to far fetched, because when templates was first added to C++, many C++ compiler would actually create a new class declaration for every new template instantiation.  Then compile the new template decloration.  So, ArrayList < String > is a completely different type than ArrayList < Integer >, and vise versa.  You can not assign a ArrayList < Integer > a variable that is declared to be of a ArrayList < String >.  UML has the same concepts.  UML actually has two different mechanism to represent generic instances. 

The first is called an anonymous classifier (In the NetBeans UML module, we use the term Derivation Classifier).  The anonymous classifier is used to define an instance of a template.  The anonymous class uses syntax to declare the template name, and the arguments being passed into the template.  The NetBeans UML currently does not use the UML notation, but instead uses a more Java like notation.

The second approach is to use a derivation edge.  You can draw a derivation edge between  a classifier and a template.  A derivation edge has bindings that are used to specify the template arguments.  The anonymous classifier is simply a shortcut, for the derivation classifier approach.  A problem with the derivation edge approach is that you there is no way to determine that a derivation is for generalizing from a class, or implementing an interface.  Code generation can try to determine if a derivation is for implementation or generalization, if Classes and interfaces are used.  However, if you start to use constructs like DataTypes to represent classifiers declared in a library things get are not so clear.  Also, when you are generalizations, and implementation links, the picture get cloudy when you start to use a third relationship to represent a super class relationships (not to mention that the derivation edge looks like an implementation link with bindings).  For these reasons the NetBeans UML module does not currently allow derivation edges to be drawn from a class to a template.  In the future when we have better support for libraries, we will probably add this feature into the tool.

Following are a few examples of how the Java generics are represented in UML. 

Example 1

The follow class declaration declares a class that extends a generic type.  The the super type is a generic instance of MyGeneric, with the argument of String.

public class MyExtendedGeneric extends MyGeneric < String >
{
}

The NetBeans UML reverse engineering module will create a class that extends a derivation classifier.  The derivation classifier will have a derivation to the MyGeneric template, and its binding will specify that argument is a String.

Myextendedgeneric

Example 2

The follow class declaration declares a class that implements a generic type.  The the super interface is a generic instance of MyGenericInterface, with the argument of String.

public class MyExtendedGeneric implements MyGenericInterface < String >
{
}

The NetBeans UML reverse engineering module will create a class that implements a derivation classifier.  The derivation classifier will have a derivation to the MyGenericInterface template, and its binding will specify that argument is a String.  For the use case the NetBeans UML module has actually extended UML.  In standard UML, an implementation link can only be created between a classifier and an interface.  However, in order to better support templates NetBeans allows an implementation to be created between classifiers and derivation classifiers as well.

Mygenericinterface

Example 3

The follow class declaration declares a class that has one data member.  The type of the data member is an instance of the generic MyGeneric, with the argument of String.

public class MyClass
{
  MyGeneric < String > myAttr = new MyGeneric < String >();
}

The NetBeans UML reverse engineering module will create a class that has an aggregation association to a derivation classifier.  The derivation classifier will have a derivation to the template MyGeneric, and its binding will specify that argument is a String.

Genericattribute

Technorati Tags: , , , ,

Posted at 01:30PM Mar 07, 2007 by Trey Spiva in UML  |  Comments[2]