Code Smells in Swift

2 Episodes

Episode 1

06:54

Meaningless Fallback Values

You're probably familiar with Swift's nil-coalescing operator. The nil-coalescing operator returns a fallback value if the statement on its left doesn't produce a value. I use it quite often and there is nothing inherently wrong with it. The code smell we discuss in this episode of Code Smells in Swift is the value the statement on the right of the nil-coalescing operator produces, the fallback value.

Episode 2

06:24

Stringly Typed Code

A magic number is a number that is used in code without much meaning due to the lack of context. Magic numbers are considered an anti-pattern because they make code harder to read, understand, and maintain. Refactoring code that uses magic numbers is also more risky and can be time-consuming.