Decomposing Swift code into modules – Intro to modular design
Tags: ios, swift, learning, mastery
Published: 2018-11-21 10:50:57

---
title: Decomposing Swift code into modules – Intro to modular design
published: true
tags: ios, swift, learning, mastery
canonical_url: https://www.essentialdeveloper.com/articles/decomposing-swift-code-into-modules-intro-to-modular-design
cover_image: https://thepracticaldev.s3.amazonaws.com/i/waltb6cejwhc6agrgyep.png
---

{% youtube E0_3uTdCVew %} [Watch on YouTube](https://www.youtube.com/watch?E0_3uTdCVew?list=PLyjgjmI1UzlT2jbk9WeqNrZhZyKpPPaWq)

In this episode, we zoom out from the component level view of [the system created previously](https://www.essentialdeveloper.com/articles/composable-code-can-be-simple-intro-to-dependency-diagrams-and-composition) and we showcase how to organize it into modules.

## Learning Outcomes

- Understand the representation of relationships of components and modules in a diagram

- Understand [how concrete or modular a system is](https://www.essentialdeveloper.com/articles/clean-ios-architecture-part-2-good-architecture-traits) from its diagram representation

- Understand that every system needs to be tailored, rather than fit a predefined template

- Understand that the process of abstracting needs to be applied incrementally

## Description

We start things off by substituting the type names in the diagram with the name of the modules they belong to. For example, the `FeedViewController` can belong to a `UI` module, since it is responsible for rendering views and gathering user interactions, and the `RemoteFeedLoader` to an `API` module, as it is responsible [for communicating with the network](https://www.essentialdeveloper.com/articles/careful-with-singleton-lookalikes-way-too-common).

Moreover, we demonstrate various kinds of organization and modularity levels, and finally, we examine the case of the famous monolith, where all components belong to a single module and discuss possible tradeoffs.

Understanding the tradeoffs and risks that each design brings can be a tremendous asset while moving forward with the development of our systems. As developers and risk managers we shouldn’t be searching for one-to-rule-them-all kind of solution (it doesn’t exist); instead, we can tailor a solution based on the available resources and requirements.

[Subscribe now to our Youtube channel](https://www.youtube.com/essentialdeveloper?sub_confirmation=1) and catch **free new episodes every week**.

* * *

We’ve been helping dedicated developers to get from low paying jobs to **high tier roles – sometimes in a matter of weeks!** To do so, we continuously run and share free market researches on how to improve your skills with **Empathy, Integrity, and Economics** in mind. If you want to step up in your career, [access now our latest research for free](https://www.essentialdeveloper.com/courses/career-and-market-strategy-for-professional-ios-developers).

* * *

Originally published at [www.essentialdeveloper.com](https://www.essentialdeveloper.com/articles/decomposing-swift-code-into-modules-intro-to-modular-design).


## Let’s connect
If you enjoyed this article, visit us at [https://essentialdeveloper.com](https://essentialdeveloper.com) and get more in-depth tailored content like this.

Follow us on: [YouTube](https://youtube.com/essentialdeveloper) • [Twitter](https://twitter.com/essentialdevcom) • [Facebook](https://facebook.com/essentialdeveloper) • [GitHub](https://github.com/essentialdevelopercom)