When specifying class fields in class diagram you can provide their types, e.g.:
- name : string
- age : int
Same with methods:
+ getName() : string
You can also omit the type if the method doesn't have/return one:
+ ClassName() // constructor
+ performCleanup() // returns void
But what if the diagram only presents some example fields (i.e. presenting the design pattern idea) and the concrete type is unimportant? Do I pick any type at random for the field or should I omit the type?
TL;DR You can omit the type and it is not obligatory, sometimes you even don't know the exact types or you just don't care, e.g. in uml-diagrams.org: Library Domain Model, UML Class Diagram Example
UML 2.4.1 Infrastructure specification says:
...10.2.5 Property
...A property is a typed element that represents an attribute of a class...
...10.1.5 TypedElement
...A typed element is a kind of named element that represents elements with types...
...Elements with types are instances of TypedElement. A typed element may optionally have no type...
See also: