Skip to content

Instantly share code, notes, and snippets.

@matiasdim
Created December 2, 2020 20:22
Show Gist options
  • Save matiasdim/8a46584ab76d6fea1655b442204f0375 to your computer and use it in GitHub Desktop.
Save matiasdim/8a46584ab76d6fea1655b442204f0375 to your computer and use it in GitHub Desktop.
Single-Responsability
class Employee {
let name: String
let emailAddress: EmailAddress
init(name: String, emailAddress: EmailAddress) {
self.name = name
self.emailAddress = emailAddress
}
func getInfo() -> String {
return "Employee named \(name) has email \(emailAddress.email)"
}
}
class EmailAddress {
let email: String
init(email: String) {
self.email = email
}
func validate() -> Boo l{
// Code that validates email
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment