0

I use a static class in my program code. does anyone know if you can mark static classes in a UML class diagram?

Edit I have a static factory called CityMapFactory in C# that produces city maps. The city cards are objects that are given to a travel guide.

Z.J
  • 301
  • 1
  • 7
  • 1
    static classes is a language specific concept that has different meanings in different languages. Can you please either add the language, or indicate what meaning you give to static classes? – Christophe Aug 22 '22 at 07:03
  • please note my editing. – Z.J Aug 22 '22 at 07:42

1 Answers1

0

The C# static classes are classes that cannot be instantiated. Moreover they are supposed to contain only static members and are sealed.

There is no static class in UML. But therer are all the tools necessesary:

  • A class that cannot be instantiated is generally called an abstract class in UML. This terminology is slightly different from some popular languages which bind this notion with the presence of abstract “methods” / “functions” / operations. Some may claim that a static class is not incomplete, however it misses a core feature that is necessary for normal classes: the means (constructors, implicit or explicit) that are needed to make it a normal class.
  • a class that is “sealed” is called a leaf class in UML. isLeaf is a property of classes in UML but there is no notation defined. U Pragmatically {leaf} is used next to the class name (this notation was defined in some previous UML versions but no longer in the current one).
  • all members are static means that they should all be shown in underlined.

If you want to quickly show that you do not mean an abstract leaf class with all members being static by coincidence, you could create a special profile that could specify your own stereotype to clarify, e.g «static class», or use an existing C# profile (check if one is delivered with your favorite modeling tool before reinventing the wheel).

Christophe
  • 68,716
  • 7
  • 72
  • 138