You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The guidelines for how Swift should be written and formatted can be found in the [Coding Style Guide](coding-style-guide.md).
15
+
16
+
### Choosing Between Structures and Classes
17
+
18
+
In addition to the [Apple guidelines](https://developer.apple.com/documentation/swift/choosing_between_structures_and_classes), we generally prefer to use `struct` for:
19
+
20
+
- Value types like the [Networking Models](../../../Networking/Networking/Model)
21
+
- Stateless helpers
22
+
23
+
But consider using `class` instead if:
24
+
25
+
- You need to manage mutable states. Especially if there are more than a few `mutating` functions, the `struct` becomes harder to reason about.
26
+
- You have to set a `struct` property declaration as `var` because it has a `mutating` function. In this case, a constant (`let`) `class` property may be easier to reason about.
0 commit comments