October 2017
Intermediate to advanced
210 pages
5h 32m
English
In the object-oriented programming example, we created a Vehicle superclass from which all the vehicle classes were derived from. In the protocol-oriented programming example, we used a combination of protocols and protocol extensions to achieve the same result; however, there are several advantages to the protocol-oriented design.
To refresh our memory of the two solutions, let's look at the code for both the Vehicle superclass and the Vehicle protocol and protocol extension. The following code shows the Vehicle superclass:
class Vehicle { fileprivate var vehicleTypes = [TerrainType]() fileprivate var vehicleAttackTypes = [TerrainType]() fileprivate var vehicleMovementTypes = [TerrainType]() ...Read now
Unlock full access