UML class diagram: is this how to write abstract method and property?

silla picture silla · Sep 28, 2012 · Viewed 22.3k times · Source

When I was creating the first time an uml class diagram for a small C# project I had some trouble with the properties. At the end I just added the properties as a variable with <<property>> at the start. Now Im wondering how do I solve this with an abstract method? Should I just add <<abstract>> to the method an fine? Im doing something like this:

-----------------------------------
|           <<abstract>>          |
|             MyClass             |
-----------------------------------
|<<property>> + a : int           |
|<<property>> + b : string        |
-----------------------------------
|<<abstract>> # Job() : void      |
|<<abstract>> # Job2() : string   |
|- SomeNonAbstractMethod() : void |
-----------------------------------

Is this alright? Any suggestions?

Answer

Christian picture Christian · Sep 28, 2012

Every "attribute" is actually a Property in UML2. Abstract methods are displayed by italic text (UML has a boolean value for this).

The notation you are using is called Keyword (simple way) or Stereotype (more complex). If you want to mark a Property as some kind of "special" that's fine with a keyword like you did.