Skip to content

Latest commit

 

History

History
87 lines (56 loc) · 2.35 KB

readme.md

File metadata and controls

87 lines (56 loc) · 2.35 KB

S.Leschev Design Patterns (Swift 5+)

Google Engineering Level: L6+

🏆 Awards

Ranking #Dev: Global TOP 300 (Certificate)

Sergey Leschev

Languages: Swift, Shell, Database (T-SQL, PL/SQL, MySQL), Concurrency (Python3).

Algorithms: linked lists, binary search, hash table, queue/stack, dfs/bfs, sort, heap/hash, two pointers, sliding window, tree, greedy problems etc.

☔ Protection Proxy

The proxy pattern is used to provide a surrogate or placeholder object, which references an underlying object. Protection proxy is restricting access.

Example

protocol DoorOpening {
    func open(doors: String) -> String
}

final class HAL9000: DoorOpening {
    func open(doors: String) -> String {
        return ("HAL9000: Affirmative, Dave. I read you. Opened \(doors).")
    }
}

final class CurrentComputer: DoorOpening {
    private var computer: HAL9000!

    func authenticate(password: String) -> Bool {

        guard password == "pass" else {
            return false
        }

        computer = HAL9000()

        return true
    }

    func open(doors: String) -> String {

        guard computer != nil else {
            return "Access Denied. I'm afraid I can't do that."
        }

        return computer.open(doors: doors)
    }
}

Usage

let computer = CurrentComputer()
let podBay = "Pod Bay Doors"

computer.open(doors: podBay)

computer.authenticate(password: "pass")
computer.open(doors: podBay)

Contacts

I have a clear focus on time-to-market and don't prioritize technical debt.

🛩️ #startups #management #cto #swift #typescript #database

📧 Email: sergey.leschev@gmail.com

👋 LinkedIn: https://linkedin.com/in/sergeyleschev

👋 Twitter: https://twitter.com/sergeyleschev

👋 Github: https://github.com/sergeyleschev

🌎 Website: https://sergeyleschev.github.io

🖨️ PDF: Download

ALT: SIARHEI LIASHCHOU