Skip to content

Instantly share code, notes, and snippets.

@joanmolinas
Last active March 8, 2018 19:04
Show Gist options
  • Save joanmolinas/d1a2919fe07d7d5a67d342f1c30bd2c7 to your computer and use it in GitHub Desktop.
Save joanmolinas/d1a2919fe07d7d5a67d342f1c30bd2c7 to your computer and use it in GitHub Desktop.
Blog.firstSolidPrinciples
class UserInformationHandler {
// MARK: - Public api
func retrieve() {
let data = request()
let user = parse(data: data)
store(user: user)
}
}
private extension UserInformationHandler {
func request() -> Data {
// Interaction with the api
// Synchronous call for simplicity
}
func parse(data: Data) -> [String: Any] {
// parse data an create a dictionary
}
func store(user: [String: Any]) {
// Store on your local database, the information of the user
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment