0

The static methods in the Python are logically linked to the class and exist within it, but they are not a member method or a class method. How can I represent it in a class diagram , How to distinguish it from the rest of the methods?

// Suppose this is the method
@staticmethod
def is_work(day):
   if day.weekday() == 4 or day.weekday() == 5:
       return False
   return True
  • In UML static methods and attributes are underlined. – Klaus D. Jul 20 '19 at 15:43
  • A static method in Python is essentially just a class method that doesn't receive the class as an implicit argument. In terms of syntax, there's little to distinguish instance, class, or static methods: they are all just class attributes bound to objects of different types. – chepner Jul 20 '19 at 15:44
  • I understand that . But in this way there will be no way to distinguish between class methods and static methods in a class diagram?? – yasser nizamli Jul 20 '19 at 16:55
  • Duplicate of https://stackoverflow.com/questions/11209240/how-to-show-usage-of-static-methods-uml-class-diagram (Sorry, can't close since I made an error the first time) – qwerty_so Jul 20 '19 at 20:06

1 Answers1

-1

Both @classmethod and @staticmethod map to the UML static property, which means that they should be rendered with an underline on a diagram.

However, there is nothing built in to UML to allow you to distinguish between them. If you use a standard name for the cls parameter then that will at least allow some visual distinction. If you want to go a little further I would suggest defining a stereotype to ensure it is obvious.