O'Reilly logo

Swift Functional Programming - Second Edition by Dr. Fatih Nayebi

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

SRP

The SRP states that every class should have a single responsibility, where a responsibility is defined as a reason to change.

This principle supports the anti-pattern where large classes play multiple roles. Classes can be large for a few reasons. A core principle of OOP is the binding of the data structure to behavior. The problem is that optimizing for data--structure encapsulation not only weakens composition characteristics, but also hides the underlying problem of explicit state. As a result, OOP code typically contains many data structures, with relatively few functions per data structure. Adding methods to a class brings pressure on the SRP, and reducing the number of methods can either make the data structure difficult to compose ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required