Rules Hub
Coding Rules Library
← Back to all rules
Rule priority, scope & exceptions
Use this to align rules with the senior-level structure (P0/P1/P2, scope, exceptions/tradeoffs).
mobile ruleP1stack specificStack: swift
swiftvalue-typesstructimmutability
Model data with structs (value types) by default
Prefer struct over class for data models to get value semantics and avoid shared-mutable-state bugs; use classes only when identity/reference is needed.
PR: mobile-canon-2026-06Created: Jul 5, 2026
Bad example
Old codeswift
| 1 | class Point { var x = 0; var y = 0 } |
Explanation (EN)
Objašnjenje (HR)
Good example
New codeswift
| 1 | struct Point { var x = 0; var y = 0 } |
Explanation (EN)
Objašnjenje (HR)