title: Using testable free functions in code
body: <p>I currently use a few worker classes in an app, which comprise of only one function. </p>
  
  <p>The function performs the action described by the class name:</p>
  
  <pre><code>protocol FooUpdatable {
    func updateFoo(with foo: SomeFoo)
  }
  
  class FooUpdater: FooUpdatable {
    let dependency: DependencyType
  
    init(dependency: DependencyType = ConcreteDependency()) {
      self.dependency = dependency
    }
  
    func updateFoo(with foo: SomeFoo) {
      ...
    }
  }
  </code></pre>
  
  <p>I am thinking some of these should be free functions, rather than in a class - but one benefit of the current architecture is testability. 
  In tests, I can swap out this dependency for a mock through the constructor injection, but am not sure how best to do this with a free function. </p>
  
  <pre><code>func updateFoo(with foo: SomeFoo, dependency: DependencyType = ConcreteDependency() {
    ...
  }
  </code></pre>
  
  <p>In Objective-C, mocking frameworks can do this through swizzling right? Any way of accomplishing the same in Swift?</p>