Skip to content

Commit 16f258e

Browse files
committed
rewrite conclusion
1 parent ec061ec commit 16f258e

File tree

1 file changed

+11
-6
lines changed
  • app/pages/learn/01_tutorial/03_getting-to-know-the-language/04_classes_objects

1 file changed

+11
-6
lines changed

app/pages/learn/01_tutorial/03_getting-to-know-the-language/04_classes_objects/01_enums.md

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ toc:
1616
- Abstract methods in enums {abstract}
1717
- Conclusion {conclusion}
1818
description: "Working with enums."
19-
last_update: 2023-09-28
19+
last_update: 2023-09-29
2020
author: ["DanielSchmid"]
2121
---
2222
<a id="intro">&nbsp;</a>
@@ -189,13 +189,18 @@ enum MyEnum {
189189
<a id="conclusion">&nbsp;</a>
190190
## Conclusion
191191

192-
All in all, enums provide a simple and safe way of limiting the instances of a type
193-
while preserving most of the flexibilities of classes.
192+
All in all, enums provide a simple and safe way of representing a fixed set of constants
193+
while keeping most of the flexibilities of classes.
194194

195195
However, care should be taken when using enums where the number (or names) of instances is subject to change.
196-
Whenever enum constants are changed, there may be compilation errors, runtime errors or other inconsistencies
197-
due to other code expecting the original version of the enum.
196+
Whenever enum constants are changed, other code expecting the old version of the enum might not work as expected.
197+
This may manifest in compilation errors (e.g. when referencing a removed enum constant),
198+
runtime errors (e.g. if there is a `default` case even though the new enum constant should be handled separately)
199+
or other inconsistencies (e.g. if the value of the enum was saved to a file which is then read and expecting that value to still exist).
200+
When changing enum constants, it is recommended to review all code using the enum.
198201
This is especially important in cases where the enum is also used by other people's code.
199202

200203
Furthermore, it might be worth considering to use other options
201-
in case of many instances since listing many instances at a single location in code can be inflexible.
204+
in case of many instances since listing a lot of instances at a single location in code can be inflexible.
205+
For example, it may be better to use a configuration file for listing all instances
206+
and reading these configuration files in the program in cases like this.

0 commit comments

Comments
 (0)