2

In http://pages.cs.wisc.edu/~hasti/cs302/examples/UMLdiagram.html it is written that "parameter names are not included in the UML class diagram"

I haven't been able to find any information on this. Most places have the parameter list written like so: functionName(arg1: type, arg2: type, ...)

So, is this information just plainly incorrect?

1
  • 2
    The UML Specification is publicly available free of charge. You can just look up the answer. I believe 9.4.4 is the clause you are looking for. Commented Oct 12, 2021 at 17:36

1 Answer 1

4

According to UML specification when you are providing list of parameters you have a possibility to provide them with names or without. The choice depends on the diagram author and the information they need to convey with the diagram. Sometimes only information about the data types of parameters are needed rather than precise specification of the names. In other cases the names are important.

In the given example the list of parameters does not contain names and the reader is being warned about that information regarding this particular diagram in the disclaimer. It does not refer to general possibility of adding or not parameters while using UML.

So it is correct information, however you apparently misinterpreted is as something referring to UML in general, rather than message about this specific diagram.

8
  • Ok, so all in all it is correct UML both with and without the parameter name, as the designer I choose whichever one is more appropriate. Did I understand it now?
    – name12345
    Commented Oct 12, 2021 at 17:36
  • 1
    "According to UML specification when you are providing list of parameters you have a possibility to provide them with names or without." – Interesting. I read the grammar in 9.4.4 such that the parameter name is mandatory. Do Class Diagrams override this definition somewhere? Commented Oct 12, 2021 at 17:40
  • 9.4.4 shows: <parameter> ::= [<direction>] <parameter-name> ’:’ <type-expression> [’[’<multiplicity-range>’]’] [’=’ <default>] [’{’ <parm-property> [’,’ <parm-property>]* ’}’] This would corroborate that parameter-name is required, seeing that it is not enclosed in square brackets. Commented Oct 12, 2021 at 20:48
  • A Parameter is a specification of TypedElement that in turn is a specification of NamedElement. NamedElement has a specification of Name attribute as follows: + name : String [0..1] (see section 7.4.2, figure 7.5 on page 27). Clearly, the attribute is optional and so should be for Parameter. I haven't seen any redefinition of this attribute so clearly Name is an optional attribute of Parameter.
    – Ister
    Commented Oct 15, 2021 at 6:49
  • (contd.) Additionally in section 9.4.3.4 it clearly states: "A Parameter may be given a name, which then identifies the Parameter uniquely within the Parameters of the same BehavioralFeature. If it is unnamed, it is distinguished only by its position in the ordered list of Parameters.". Section 9.4.4 is clearly inconsistent with the rest of the Specification in this regard.
    – Ister
    Commented Oct 15, 2021 at 6:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.