76

How would you create an uml class diagram for constructors with parameters?

For default constructors (no parameters) you do

  • policyholder() for the diagram and in the pseudo-code

For constructors with parameters would you do the same thing:

  • policyholder (policynumber, service class, and customer age) for class diagrams and pseudo-code.

It also asked to initialize each attribute to value where an object of this type can be instantiated. If a policy number is not between 1000 and 999 inclusive, then set the policy number to 0. (policy number is attribute)

1 Answer 1

129

The common way is to write constructors like methods and simply omit the return type.

enter image description here

If you want to be extra clear, you can add <<constructor>> in front.

3
  • 35
    UML can be sometimes a nitpickers dream, I found out that it's actually <<Create>>, see UML 2.5.1 page 198 (PDF-page number 240)
    – Ciantic
    Oct 21, 2018 at 20:56
  • 10
    @Ciantic The page numbering is still right, but the document moved to omg.org/spec/UML/2.5.1/PDF Thanks for your comment!
    – Clément
    Mar 20, 2019 at 16:28
  • 1
    Page 195/745 now :)
    – NickW
    Apr 3 at 11:51

Your Answer

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

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