A collection of design pattern implementations in Swift
Explore practical examples of software design patterns written in clean, modern Swift.
- Unit of Work — Aggregate operations under a single transaction interface.
(Add more patterns here as you expand the project.)
hg-swift-patterns/
├── creational/
│ └── UnitOfWork.swift
├── structural/
├── behavioral/
└── LICENSE
- Each folder represents a category of design patterns.
- Files contain focused, easy-to-read Swift code demonstrating each pattern.
git clone https://github.com/hgq287/hg-swift-patterns.git
cd hg-swift-patterns
Open the project or .swift
files directly in Xcode to explore and run each pattern.
You can also create a Swift Playground and import the source code for easier experimentation.
let repository = Repository()
let unitOfWork = UnitOfWork(repository: repository)
unitOfWork.perform {
// Queue multiple data operations
}.commit()
- Swift 5+
- Xcode 16 or newer
- macOS or iOS development environment
Want to contribute another pattern or improve an existing one? Feel free to:
- Fork the repository
- Submit a pull request
- Open an issue to discuss improvements
This project is licensed under the MIT License.
Maintained by @hgq287.
Feel free to reach out or share improvements.