DEV Community

Sergey Leschev
Sergey Leschev

Posted on β€’ Edited on

2 2 1 1 1

πŸ”‚ Monostate Pattern

The monostate pattern is another way to achieve singularity. It works through a completely different mechanism, it enforces the behavior of singularity without imposing structural constraints. So in that case, monostate saves the state as static instead of the entire instance as a singleton. SINGLETON and MONOSTATEβ€Š-β€ŠRobert C. Martin

Github https://github.com/sergeyleschev/design-patterns

Example:

class Settings {

    enum Theme {
        case `default`
        case old
        case new
    }

    private static var theme: Theme?

    var currentTheme: Theme {
        get { Settings.theme ?? .default }
        set(newTheme) { Settings.theme = newTheme }
    }
}
Enter fullscreen mode Exit fullscreen mode

Usage:

import SwiftUI
// When change the theme
let settings = Settings() // Starts using theme .old
settings.currentTheme = .new // Change theme to .new
// On screen 1
let screenColor: Color = Settings().currentTheme == .old ? .gray : .white
// On screen 2
let screenTitle: String = Settings().currentTheme == .old ? "Itunes Connect" : "App Store Connect"
Enter fullscreen mode Exit fullscreen mode

Sources: Github

Creational
In software engineering, creational design patterns are design patterns that deal with object creation mechanisms, trying to create objects in a manner suitable to the situation. The basic form of object creation could result in design problems or added complexity to the design. Creational design patterns solve this problem by somehow controlling this object creation.
Source: wikipedia.org


🐝 Chain Of Responsibility
πŸ‘« Command Pattern
🎢 Interpreter Pattern
🍫 Iterator Pattern
πŸ’ Mediator Pattern
πŸ’Ύ Memento Pattern
πŸ‘“ Observer Pattern
πŸ‰ State Pattern
πŸ’‘ Strategy Pattern
πŸ“ Template Method
πŸƒ Visitor Pattern
🌰 Abstract Factory
πŸ‘· Builder Pattern
🏭 Factory Method
πŸ”‚ Monostate Pattern
πŸƒ Prototype Pattern
πŸ’ Singleton
πŸ”Œ Adapter Pattern
πŸŒ‰ Bridge Pattern
🌿 Composite Pattern
🍧 Decorator Pattern
🎁 Facade Pattern
πŸƒ Flyweight Pattern
β˜” Protection Proxy
🍬 Virtual Proxy


Contacts
I have a clear focus on time-to-market and don't prioritize technical debt. And I took part in the Pre-Sale/RFX activity as a System Architect, assessment efforts for Mobile (iOS-Swift, Android-Kotlin), Frontend (React-TypeScript) and Backend (NodeJS-.NET-PHP-Kafka-SQL-NoSQL). And I also formed the work of Pre-Sale as a CTO from Opportunity to Proposal via knowledge transfer to Successful Delivery.

πŸ›©οΈ #startups #management #cto #swift #typescript #database
πŸ“§ Email: sergey.leschev@gmail.com
πŸ‘‹ LinkedIn: https://linkedin.com/in/sergeyleschev/
πŸ‘‹ LeetCode: https://leetcode.com/sergeyleschev/
πŸ‘‹ Twitter: https://twitter.com/sergeyleschev
πŸ‘‹ Github: https://github.com/sergeyleschev
🌎 Website: https://sergeyleschev.github.io
🌎 Reddit: https://reddit.com/user/sergeyleschev
🌎 Quora: https://quora.com/sergey-leschev
🌎 Medium: https://medium.com/@sergeyleschev
πŸ–¨οΈ PDF Design Patterns: Download

Do your career a big favor. Join DEV. (The website you're on right now)

It takes one minute, it's free, and is worth it for your career.

Get started

Community matters

Top comments (0)