October 2017
Intermediate to advanced
210 pages
5h 32m
English
To demonstrate the facade pattern, we will create three APIs: HotelBooking, FlightBooking, and RentalCarBooking. These APIs will be used to search for and book hotels, flights, and rental cars for trips. While it would be very easy to call each of the APIs individually, we are going to create a TravelFacade structure that will consolidate the functionality of all three APIs into a single call.
Let's begin by defining the three APIs. We will start off by implementing the hotel API:
struct Hotel {
//Information about hotel room
}
struct HotelBooking {
static func getHotelNameForDates(to: NSDate, from: NSDate) -> [Hotel]? { let hotels = [Hotel]() //logic to get hotels return hotels } static func bookHotel(hotel: ...Read now
Unlock full access