Better Programming

Advice for programmers.

Follow publication

Member-only story

Swift 5.1 Takes Dependency Injection to the Next Level

Michael Long
Better Programming
Published in
12 min readJul 1, 2019

Swift 5.1 brings many new features to the language, and several of them promise to revolutionize how we write and structure our Swift code.

This article will discuss Swift Property Wrappers and demonstrate just one way they can be used to dramatically simplify your code.

UPDATE: The following article has been updated to reflect changes in Swift 5.2.

Some Background

Modern software development is an exercise in managing complexity, and one of the ways we attempt to do that is via architecture. Architecture, in turn, is really just a term used to describe how we break complex software down into easily digestible layers and components.

So we follow the rules and break our software down into simplified components that can be easily written, do just one thing (SRP), and can be easily tested.

Once we have our pile of parts, however, we have to wire everything back together again to form a working application. Figures.

Wire things together the right way, and we have a neat structure formed from a loosely coupled set of components.

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Michael Long
Michael Long

Written by Michael Long

I write about Apple, Swift, and SwiftUI in particular, and technology in general. I'm also a Lead iOS Engineer at InRhythm, a modern digital consulting firm.

Write a response