Browse Questions
- NavigationStack (iOS 16+) replaces NavigationView and uses a path-based approach for programmatic navigation, making deep linking and state-driven navigation much cleaner.
- Define a clear error type, validate HTTP status codes, and propagate errors up to the UI where they can be shown to the user.
- SOLID is a set of five design guidelines for maintainable OOP code: | Principle | Idea | Swift application | |--|--|--| | Single Responsibility | A type should have one reason to change | Split a…
- Themis is an open-source, cross-platform cryptographic library that packages a few high-level, hard-to-misuse primitives instead of exposing raw ciphers.
Answer: SOLID is a set of five design guidelines for maintainable OOP code:
| Principle | Idea | Swift application |
|---|---|---|
| Single Responsibility | A type should have one reason to change | Split a "God ViewController" into a ViewModel + Service |
| Open/Closed | Open for extension, closed for modification | Add behavior via protocol conformance/extensions, not by editing existing types |
| Liskov Substitution | Subtypes must be usable wherever their base type is expected | A Square: Rectangle shouldn't break callers that resize rectangles independently |
| Interface Segregation | Prefer many small protocols over one large one | Codable is Encodable & Decodable — adopt only what you need |
| Dependency Inversion | Depend on abstractions, not concrete types | Inject a NetworkClientProtocol, not a concrete URLSessionClient |
// Interface Segregation + Dependency Inversion together
protocol UserFetching {
func fetchUser(id: String) async throws -> User
}
final class ProfileViewModel {
private let fetcher: UserFetching // depends on an abstraction
init(fetcher: UserFetching) {
self.fetcher = fetcher
}
}