Question

I have the following constructor in a class for a code I'm writing an assignment on for school:

public Plant(int xPos, int yPos,int width,int height, int hp,String imageLocation,String audioLocation,Stage stage)

The only parameter I find valuable to show in the UML diagram I'm creating is Stage. Could the other parameters be omitted then? This is the only constructor in the class so there is no chance of confusion in regard to that. Though, I suppose one could get confused to not find the method when searching through the actual code later on?

Edit: I'm interested in the advice of UML practitioners using UML diagrams outside of university, and not opinions on what could please my teacher (see comments).

Was it helpful?

Solution

The only UML diagram this is likely to apply to is the Class Diagram.

In a class diagram, the constructor is treated as merely another method. It is sometimes prefixed with <<create>>, or the return type omitted, to indicate that it is a constructor; but it is a method like any other nevertheless.

In a typical UML class diagram, methods are indicated using their entire signature. I would therefore expect all of the parameters to be present, even in the constructor method.

Licensed under: CC-BY-SA with attribution
scroll top