I liked the approach of builders for solving complex logic and specifically the block-based builder design.

I have a single concern that if for simple data models we are using builders, which essentially is an additional component, can’t we have the same flexibility with structs and a default value nil for optionals.

struct OptionDetailDataStruct: Equatable {let isExpired: Boollet expiryDate: String?let cardNumber: String?let formattedNumber: String?let phoneNumber: String?init(isExpired: Bool, expiryDate: String? = nil, cardNumber: String? = nil, formattedNumber: String? = nil, phoneNumber: String? = nil) {self.isExpired = isExpiredself.expiryDate = expiryDateself.cardNumber = cardNumberself.formattedNumber = formattedNumberself.phoneNumber = phoneNumber}}



Software Developer(iOS), Speaker & Writer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store