Stringly Typed? "A riff on "strongly typed". Used to describe an implementation that needlessly relies on strings when programmer & refactor friendly options are available." — Internet
Stringly Typed? "A riff on "strongly typed". Used to describe an implementation that needlessly relies on strings when programmer & refactor friendly options are available." — Internet // Stringly typed let image = UIImage(named: "PalletTown") // Strongly typed let tableView = UITableView(style: .Plain)
Swift 3: Set API Old .setBool(true, forKey: "isUserLoggedIn") .setInt(1, forKey: "pokeballCount") .setObject(pikachu, forKey: "pikachu") New .set(true, forKey: "isUserLoggedIn") .set(1, forKey: "pokeballCount") .set(pikachu, forKey: "pikachu")
Swift 3: Get API Old .boolForKey("isUserLoggedIn") .integerForKey("pokeballCount") .objectForKey("pikachu") New .bool(forKey: "isUserLoggedIn") .integer(forKey: "pokeballCount") .object(forKey: "pikachu")
So what have we learned? • Stringly typed API's are bad • Plenty of room for improvement • Grouping constants can assist uniformity • Namespacing gives context
So what have we learned? • Stringly typed API's are bad • Plenty of room for improvement • Grouping constants can assist uniformity • Namespacing gives context • Protocols are (so) hot right now
So what have we learned? • Stringly typed API's are bad • Plenty of room for improvement • Grouping constants can assist uniformity • Namespacing gives context • Protocols are (so) hot right now • Rethink how we interact with APIs