Andrew Bancroft 5/5/2016

Working with Swift: Adopt a Protocol or Pass a Function?

Read Original

This article discusses a key architectural decision in Swift development: whether to create and adopt a protocol or simply pass a function. Drawing from Rob Napier's dotSwift 2016 talk, it provides rules of thumb for when each approach is more appropriate. For single-function or short-lived dependencies, passing a function is simpler and more concise. For multiple related functions or long-lived relationships, protocols offer cleaner abstraction. The article includes practical examples and guidance to help developers make informed design choices, emphasizing clarity and simplicity in Swift code.

Working with Swift:  Adopt a Protocol or Pass a Function?

Comments

No comments yet

Be the first to share your thoughts!

Browser Extension

Get instant access to AllDevBlogs from your browser