SwiftletModel
Related: iOS App Development, Software Engineering
SwiftletModel is an in-memory key-value entity storage with a twist.
- Entities as Plain Structs: It allows to design of app domain models as plain Swift structs.
- Bidirectional Relations: It manages relationships between entities automatically
- Normalized In-Memory Storage: It stores entities in a normalized form to avoid duplication and inconsistency.
- On-the-Fly Denormalization: It allows to transform data on-the-fly to any required shape of nested entities.
- Incomplete Data Handling: it provides a way to reliably handle incomplete data without corruption.
- Codable Out of the Box: Plain struct models allow to get Codability conformance for free turning your in-memory model layer into persistable storage
Read the story behind SwiftletModel.
SwiftletModel Use Cases
The ideal SwiftletModel use case falls somewhere between fully-fledged database persistent storage solutions like CoreData, SwiftData, Realm, or SQLite and the plain serialization to a file.
You basically get the best of the two worlds:
- Relational object graph management, like in CoreData
- Simplicity of plain Swift struct and file storage.
That was the primary use case. In practice, it turned out that SwiftletModel capabilities are much broader.
More detailed SwiftletModel case studies:
- Parsing Server Response with Codable SwiftletModel Entities
- [[Using SwiftletModel as Normalized Response Cache]]
- [[Application Core Domain Model Design with SwiftletModel]]
- [[iOS App Persistent Layer Implementation with SwiftletModel]]
- [[SwiftletModel on Server: Using SwiftletModel as Vapor DTOs]]
Comments