Notes 13-May-2026
-
-
Save byJeevan/323558c07c82f3cb50989e196ad27ddc to your computer and use it in GitHub Desktop.
Pagination: Cursor vs Offset based.
SOLID Principle [p0]
The SOLID principles are 5 design principles used to write clean, maintainable, and scalable code.
-
S — Single Responsibility Principle (SRP)
A class should have only one reason to change.
→ One class = one responsibility. -
O — Open/Closed Principle (OCP)
Code should be open for extension but closed for modification.
→ Add new behavior without changing existing code. -
L — Liskov Substitution Principle (LSP)
Subclasses should be replaceable for their parent classes without breaking behavior.
→ Child class must behave correctly as parent. -
I — Interface Segregation Principle (ISP)
Don’t force classes to implement methods they don’t need.
→ Create small, specific interfaces. -
D — Dependency Inversion Principle (DIP)
Depend on abstractions, not concrete implementations.
→ Use protocols/interfaces instead of direct class dependency.
Simple iOS Example
Instead of:
class NetworkManager {
func fetch() {}
}Prefer:
protocol Networking {
func fetch()
}
class NetworkManager: Networking {
func fetch() {}
}
class HomeViewModel {
let network: Networking
init(network: Networking) {
self.network = network
}
}This follows DIP and improves testing & flexibility.
How optionals implemented under the hood ?
Working of Retain count ?
Higher order functions compactMap, reduce etc ?
Copy on write concept
class vs Actor vs MainActor , re- entrancy problem ?
let vs var
class vs struct
mutable vs immutable
Any vs AnyObject
@escaping and non-escaping
Array vs Array slice vs collection of one