ochococo / Design-Patterns-In-Swift
π Design Patterns implemented in Swift 5.0
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.
Repository Overview (README excerpt)
Crawler viewDesign 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_