Home

Awesome

iOSModuleArchitecture

Questions and feedbacks are welcomed in the issues part of the repository!

Introduction

Quick example of how divide an app into modules to respect the SOLID principles based on the VIPER architecture.

In this application, there are two modules. The first one retrieve a model which contains a string from the (fake) remote data store in order to send the string and display it in the second module.

How to start the app

After downloading the repository, be sure that you already installed CocoaPods and run the command pod install in the directory of the repository through a terminal. Then open the file named iOSModuleArchitecture.xcworkspace.

Architecture

Class diagram

This class diagram represents the modelization of the main module - FirstModule - of this app

class diagram

As you can see with the stereotypes on the class diagram there are different design patterns used in this module:

FAQ

Q: Isn't it overkill such a decomposition?
A: I took the habit to always decompose the features of an app in modules. The decomposition shown in this repository is an example of a complete decomposition that respects SOLID principles. Feel free to adapt it to your project's requirements. Such an implementation permits to the modules to be interchangeable, highly scalable and highly abstracted. If you're afraid that you will take too much time to implement a whole app using this architecture keep in mind two facts. Firstly, you can create tools to automate the creation of module with all the boilerplate code. And you will loose less time to take the time to think to a good-enough architecture rather than program a cheap one and rewrite a lot of code when the first version of the project starts to be unmanageable.

Q: How can I transfer objects from one module to another?
A: CoreData is the perfect tool for this. Send the string entity id of the stored object to your second module, then retrieve the object from core data using the entity id.