3.1.1 How to Represent Properties in a Class Diagram

For this example we will be looking at the code below. Note there are some properties and methods in the class that I don't show later on.

The proper way to show the two properties IsGood and Name is shown below.

Note that the properties are shown in the method block of the class node and are between the constructor and any methods. This follows where properties should be placed in your code.


Properties in class diagrams will always be public and be the capitalized version of their corresponding field and have their return type shown just like a method would. They will also have either <get> or <set> following the return type. In this case, IsGood has both a getter and a setter so we show both, but Name only has a getter so we don't show a setter.