Skip to content

Commit e0a308f

Browse files
authored
add paragraph about tri state
1 parent d2435ec commit e0a308f

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

graph/GuidelinesGraph.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,36 @@ By using an evolvable enum, instead, all we need to do is to add new members:
398398
</EnumType>
399399
```
400400

401+
Similarly speaking, if you find yourself using a `nullable` Enum, that is a indication that maybe what you are trying to model is something that has 3 states and an enum is more appropraite. For instance, let's assume we have a boolean property called `syncEnabled`, where `null` means that the value is undefined and inherited from the general tenant configuration. Instead of modelling like a boolean:
402+
403+
```xml
404+
<Property Name="syncEnabled" Type="Edm.Boolean" Nullable="true"/>
405+
```
406+
407+
An enum not only better conveys the message:
408+
409+
```xml
410+
<EnumType Name="syncState">
411+
<Member Name="enabled" Value="0" />
412+
<Member Name="disabled" Value="1" />
413+
<Member Name="tenantInherit" Value="2" />
414+
<Member Name="unknownFutureValue" Value="3" />
415+
</EnumType>
416+
```
417+
418+
but it is also open for future scenarios:
419+
420+
```diff
421+
<EnumType Name="syncState">
422+
<Member Name="enabled" Value="0" />
423+
<Member Name="disabled" Value="1" />
424+
<Member Name="tenantInherit" Value="2" />
425+
<Member Name="unknownFutureValue" Value="3" />
426+
+ <Member Name="groupInherit" Value="4" />
427+
</EnumType>
428+
```
429+
430+
401431

402432
## API contract and non-backward compatible changes
403433

0 commit comments

Comments
 (0)