From the course: Swift 5: Protocol-Oriented Programming

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Highlighting the differences

Highlighting the differences

From the course: Swift 5: Protocol-Oriented Programming

Start my 1-month free trial

Highlighting the differences

- Let's summarize the benefits of the protocol oriented approach over the class-based design. Starting with the class that implements all requirements leads to the so-called god-object. A class that has too many responsibilities. Having such classes introduces tight-coupling, a severe decease of object oriented systems. As more and more objects depend on each other code changes will tend to spread across the code base. Fixing bugs or adding new features becomes a tedious, error prone task. Subclassing helps us solve the god-object problem and we manage to create a granular design; however, subclassing might lead to another problem known as type explosion. Besides, inheritance doesn't work with value types. The protocol based design addresses all the issues without side effects. The result in design is flexible and it works perfectly with both classes and value types. By adopting multiple protocols, we can create types…

Contents