back to home

ochococo / Design-Patterns-In-Swift

πŸ“– Design Patterns implemented in Swift 5.0

15,267 stars
1,744 forks
4 issues
SwiftShell

AI Architecture Analysis

This repository is indexed by RepoMind. By analyzing ochococo/Design-Patterns-In-Swift in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.

Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.

Source files are only loaded when you start an analysis to optimize performance.

Embed this Badge

Showcase RepoMind's analysis directly in your repository's README.

[![Analyzed by RepoMind](https://img.shields.io/badge/Analyzed%20by-RepoMind-4F46E5?style=for-the-badge)](https://repomind.in/repo/ochococo/Design-Patterns-In-Swift)
Preview:Analyzed by RepoMind

Repository Overview (README excerpt)

Crawler view

Design Patterns implemented in Swift 5.0 ======================================== A short cheat-sheet with Xcode 10.2 Playground (Design-Patterns.playground.zip). πŸ‡¨πŸ‡³δΈ­ζ–‡η‰ˆ πŸ‘· Project started by: @nsmeme (Oktawian Chojnacki) πŸ‘· δΈ­ζ–‡η‰ˆη”± @binglogo (棒棒彬) 整理翻译。 πŸš€ How to generate README, Playground and zip from source: CONTRIBUTING.md Table of Contents | Behavioral | Creational | Structural | | ------------------------------------------------------ | ---------------------------------------- | ---------------------------------------- | | 🐝 Chain Of Responsibility | 🌰 Abstract Factory | πŸ”Œ Adapter | | πŸ‘« Command | πŸ‘· Builder | πŸŒ‰ Bridge | | 🎢 Interpreter | 🏭 Factory Method | 🌿 Composite | | 🍫 Iterator | πŸ”‚ Monostate | 🍧 Decorator | | πŸ’ Mediator | πŸƒ Prototype | 🎁 FaΓ§ade | | πŸ’Ύ Memento | πŸ’ Singleton | πŸƒ Flyweight | | πŸ‘“ Observer | | β˜” Protection Proxy | | πŸ‰ State | | 🍬 Virtual Proxy | | πŸ’‘ Strategy | | | | πŸ“ Template Method | | | | πŸƒ Visitor | | | Behavioral ========== >In software engineering, behavioral design patterns are design patterns that identify common communication patterns between objects and realize these patterns. By doing so, these patterns increase flexibility in carrying out this communication. > >**Source:** wikipedia.org 🐝 Chain Of Responsibility -------------------------- The chain of responsibility pattern is used to process varied requests, each of which may be dealt with by a different handler. Example: Usage πŸ‘« Command ---------- The command pattern is used to express a request, including the call to be made and all of its required parameters, in a command object. The command may then be executed immediately or held for later use. Example: Usage: 🎢 Interpreter -------------- The interpreter pattern is used to evaluate sentences in a language. Example Usage 🍫 Iterator ----------- The iterator pattern is used to provide a standard interface for traversing a collection of items in an aggregate object without the need to understand its underlying structure. Example: Usage πŸ’ Mediator ----------- The mediator pattern is used to reduce coupling between classes that communicate with each other. Instead of classes communicating directly, and thus requiring knowledge of their implementation, the classes send messages via a mediator object. Example Usage πŸ’Ύ Memento ---------- The memento pattern is used to capture the current state of an object and store it in such a manner that it can be restored at a later time without breaking the rules of encapsulation. Example Originator Caretaker Usage πŸ‘“ Observer ----------- The observer pattern is used to allow an object to publish changes to its state. Other objects subscribe to be immediately notified of any changes. Example Usage πŸ‰ State --------- The state pattern is used to alter the behaviour of an object as its internal state changes. The pattern allows the class for an object to apparently change at run-time. Example Usage πŸ’‘ Strategy ----------- The strategy pattern is used to create an interchangeable family of algorithms from which the required process is chosen at run-time. Example ### Usage πŸ“ Template Method ----------- The template method pattern defines the steps of an algorithm and allows the redefinition of one or more of these steps. In this way, the template method protects the algorithm, the order of execution and provides abstract methods that can be implemented by concrete types. Example Usage πŸƒ Visitor ---------- The visitor pattern is used to separate a relatively complex set of structured data classes from the functionality that may be performed upon the data that they hold. Example `swift protocol PlanetVisitor { func visit(planet: PlanetAlderaan) func visit(planet: PlanetCoruscant) func visit(planet: PlanetTatooine) func visit(planet: MoonJedha) } protocol Planet { func accept(visitor: PlanetVisitor) } final class MoonJedha: Planet { func accept(visitor: PlanetVisitor) { visitor.visit(planet: self) } } final class PlanetAlderaan: Planet { func accept(visitor: PlanetVisitor) { visitor.visit(planet: self) } } final class PlanetCoruscant: Planet { func accept(visitor: PlanetVisitor) { visitor.visit(planet: self) } } final class PlanetTatooine: Planet { func accept(visitor: PlanetVisitor) { visitor.visit(planet: self) } } final class NameVisitor: PlanetVisitor { var name = "" func visit(planet: PlanetAlderaan) { name = "Alderaan" } func visit(planet: PlanetCoruscant) { name = "Coruscant" } func v _...truncated for preview_