In support to blog post https://codewithshabib.com/2017/02/25/dealing-with-telescopic-constructors-anti-pattern/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum OrderSize { | |
case small | |
case medium | |
case large | |
} | |
enum SpiceRange { | |
case spicy | |
case hot | |
case extraHot | |
} | |
class Biriyani { | |
let count: Int | |
let size: OrderSize | |
let spiceRange: SpiceRange | |
init (count: Int, size: OrderSize, spiceRange: SpiceRange) { | |
self.count = count | |
self.size = size | |
self.spiceRange = spiceRange | |
} | |
} | |
class Restaurant { | |
var biriyani = Biriyani(count: 1, size: .medium, spiceRange: .extraHot) | |
... | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment