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

Granularity mismatch

FP and OOP operate on different design-granularity levels. While in FP, functions/methods are the most important building blocks and programming is done at a low level, in OOP, classes/objects/modules are the most important building blocks and programing is done at a high level.

To overcome this granularity mismatch, we need to find answers for the following questions:

  • Where do we locate the source of individual functions in an OOP architecture?
  • Where do we relate such individual functions to an OOP architecture?

In Swift, we can place functions inside source files and outside of classes, or we can place them as static or class methods.

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