Re: UML: Is it allowed to introduce custom stereotypes on classes? What about methods?



H. S. Lahman wrote:
Responding to Kaeppler...

we had the problem to model a Java 5 enumeration in a class diagram in UML, and our approach was to just model it as a usual class and put a {enumeration} after the class name.
Is that okay? I know UML knows such things as {abstract}, but is it okay to shamelessly plug in your own stereotypes?


No, it's not OK but for an entirely different reason.  B-)

Java 5 enumeration is a specific OOPL feature. It has no business being in an OOA/D model. The goal of OOA/D modeling is not to reduce OOP to such a rote exercise that it can be done by a reasonably intelligent orangutan if one has a large bag of bananas. The OOA/D model should be an abstract solution that is independent of particular OOPL syntax and semantics. One /implements/ such a model at the OOP level using the language features at hand.


But how should I model it then? Like a normal class with only public static members?



We also did this with methods:
Since we use a very limited modelling tool, which had no means of modelling methods as abstract or even static, we e.g. modelled a static method like this:


+ foo() : void {static}

Is that okay?


If the tool does not allow one to distinguish class methods from instance methods or virtual methods from concrete methods, then one has to cope somehow. However, I would try to use a more abstract description since the notion of 'static' is very OOPL-specific. The real issue insofar as OOA/D is concerned is whether the method is associated with a specific instance.


Yes, that's what static means in Java and other OO languages in the C family, it's a class wide method, in that it's not associated to a specific instance of a class.


What term do you suggest instead?


************* There is nothing wrong with me that could not be cured by a capful of Drano.

H. S. Lahman
hsl@xxxxxxxxxxxxxxxxx
Pathfinder Solutions  -- Put MDA to Work
http://www.pathfindermda.com
blog: http://pathfinderpeople.blogs.com/hslahman
(888)OOA-PATH





--
Matthias Kaeppler
.



Relevant Pages