Skip to content

Instantly share code, notes, and snippets.

@aainaj
Last active February 13, 2019 02:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aainaj/e3adbcf7bfc3a977dbbb5cee84514cf1 to your computer and use it in GitHub Desktop.
Save aainaj/e3adbcf7bfc3a977dbbb5cee84514cf1 to your computer and use it in GitHub Desktop.
Dependency Inversion Bad Example
struct User {
let name: String
let identifier: String
}
final class UserTransaction {
private let dataBase: DataBase
init(dataBase: DataBase) {
self.dataBase = dataBase
}
func add(user: User) {
dataBase.insert(user)
}
func edit(user: User) {
dataBase.update(user)
}
func delete(identifier: String) {
dataBase.delete(identifier: identifier)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment