Search code examples
umlclass-diagramclass-methodclass-variables

Representing class variables and methods in UML


Many programming languages allow you to define class/instance methods, and the same for attributes. E.g. Python, Smalltalk. I have the concepts. E.g. for instance variables, every object has it’s own copy of the variables. Class variables only have one copy of the variables shared with all instances of the class.

My doubt is: how do I represent class methods and class attributes in UML? I was thinking in represent it through static, as in C++, Java, and C#, but is it ok? "static" and "class" are the same in UML?


Solution

  • Static attributes/operations1 need to be underlined. See also Class diagrams

    enter image description here

    1The term method is used for behavior (the howto) in UML. An operation is the term used in UML for a BehaviorialFeature that can be called on an interface (which is what you find in the compartment underneath the attributes).