Google Engineering Level: L6+
Ranking #Dev: Global TOP 300 (Certificate)
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.
The decorator pattern is used to extend or alter the functionality of objects at run- time by wrapping them in an object of a decorator class. This provides a flexible alternative to using inheritance to modify behaviour.
protocol CostHaving {
var cost: Double { get }
}
protocol IngredientsHaving {
var ingredients: [String] { get }
}
typealias BeverageDataHaving = CostHaving & IngredientsHaving
struct SimpleCoffee: BeverageDataHaving {
let cost: Double = 1.0
let ingredients = ["Water", "Coffee"]
}
protocol BeverageHaving: BeverageDataHaving {
var beverage: BeverageDataHaving { get }
}
struct Milk: BeverageHaving {
let beverage: BeverageDataHaving
var cost: Double {
return beverage.cost + 0.5
}
var ingredients: [String] {
return beverage.ingredients + ["Milk"]
}
}
struct WhipCoffee: BeverageHaving {
let beverage: BeverageDataHaving
var cost: Double {
return beverage.cost + 0.5
}
var ingredients: [String] {
return beverage.ingredients + ["Whip"]
}
}
var someCoffee: BeverageDataHaving = SimpleCoffee()
print("Cost: \(someCoffee.cost); Ingredients: \(someCoffee.ingredients)")
someCoffee = Milk(beverage: someCoffee)
print("Cost: \(someCoffee.cost); Ingredients: \(someCoffee.ingredients)")
someCoffee = WhipCoffee(beverage: someCoffee)
print("Cost: \(someCoffee.cost); Ingredients: \(someCoffee.ingredients)")
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