Modern Swift API Design - kirseia/study GitHub Wiki
Modern Swift API Design
- Clarity at the point of use
- No Prefixes in Swift-only Frameworks
reference or values?
- struct 를 선호하는게 좋음
- class는
- reference counting 을 관리하고 싶을 때
- value를 중앙와 하고 공유하고 싶을 때
- Where there is a separate notion of “identity” from “equality" (identity 와 equality를 분리하고 싶을 때)
protocol
- 프로토콜은 유즈 케이스를 가지고 만들어야 함
- generic code가 필요할 때
- 기존 프로토콜 합으로 해결을 먼저 시도하기
- 프로토콜보다 generic tyep을 먼저 고려해보기
Property Wrappers
매번 쓰는 코드를 줄여 줄 수 있음
@UserDefault(key: "BOOSTER_IGNITED", defaultValue: false)
static var isBoosterIgnited: Bool