Be Okay with Problem-Free Dependencies

Law enforcement agents learn how to detect counterfeit money by studying genuine money. Let’s apply this idea to dependencies. Before looking at difficult dependencies, let’s see what makes some dependencies problem-free.

Consider the following function:

 func​ ​shoutHello​(to name: ​String​) -> ​String​ {
 return​ ​"HELLO, ​​\(​name.​uppercased​()​)​​!"
 }

What dependencies does it have? This is a trick question because it’s easy to reply, “It has no dependencies.” But it does depend on the Swift String type. Our function calls the uppercased method. Swift takes the result and does string interpolation. String interpolation prefers calling the description property of the CustomStringConvertible ...

Get iOS Unit Testing by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.