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

Best practices in function definition

There are proven best practices for function and method definition provided by amazing software engineering resources, such as Clean Code: A Handbook of Agile Software Craftsmanship, by Robert C. Martin, Code Complete: A Practical Handbook of Software Construction, Second Edition, by Steve McConnell, and Coding Horror (https://blog.codinghorror.com/code-smells/), that we can summarize as follows:

  • Try not to exceed 8-10 lines of code in each function as shorter functions or methods are easier to read, understand, and maintain.
  • Keep the number of parameters minimal because the more parameters a function has, the more complex it is.
  • Functions should have at least one parameter and at least one return value. ...

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