javamethodsumlmainclass

UML Diagram for methods in main class


I'm working on my project and wondering whether if I should represent all the methods in the main class as static by drawing a line under the name of the methods including the main method.

For example:

-------------------
    MainClass
-------------------

-------------------

+Main()
______

+Othermethod()
______________

-------------------

Should I keep the line under the othermethod() or I should remove it and keep it only under the main method?


Solution

  • The static operations of a class, whether main() or other should be underlined. Non static operations should not be underlined:

    enter image description here

    If you'd make shortcuts on this notation, only showing some of the static methods as static, your model would be confusing, and could lead to errors in the implementation.

    If you're using ASCII art, the underlining is very cumbersome and confusing. In this case, you should prefer the {static} adornment, in textual form:

    ,---------------------------------.
    |MainClass                        |
    |---------------------------------|
    |...                              |
    |+{static} main()                 |
    |+otherNonStaticOperation()       |
    |+{static} otherStaticOperation() |
    `---------------------------------'
    

    By the way, plantuml can generate both, graphic and ascii art, for the same model:

    @startuml
    skinparam style strictuml
    skinparam classAttributeIconSize 0
    
    class MainClass {
      ...
      +{static} main()
      +otherNonStaticOperation()
      +{static} otherStaticOperation()  
    }
    @enduml