Skip to content

jjrebollo/modules-mvvm-c

Repository files navigation

modules-mvvm-c

Skeleton of MVVM-C architecture modularised

Proposed Architecture

This project is a proposal on how to implement MVVM-C architecture using modules in an iOS project.

This approach was chosen as it gives the project a high level of:

  • Scalability
  • Testability
  • Modularisation
  • Reusability
  • Readability

Uncle Bob guidelines on SOLID principles and clean architecture were applied. This article was used as a base to implement this architecture.

High level diagram

Alt text

Elements

  • Service: It will be the external interface. It'll interact with the Collaborator in order to trigger some network requests, notifications, phone devices (such as GPS, accelerometer, etc), etc.
  • Collaborator: It shapes up the information coming from the service into entities so Use cases receive a clean object to work with. It's also known as Interface adapters.
  • Use case: It receives the necessary information from Collaborator and applies application business rules for the feature at hand.
  • Entity: Encapsulate the information coming from outside the application into objects. It applies enterprise business rules. Also know as Model.
  • View model: Interface between the Use case and the Views. It receives the information coming from Use case and transform it to UI elements. Also, receives UI interactions and forward this info to the Use case so Application business rules can be applied.
  • View: UI elements such as labels, buttons, picker views, etc. It's what the user will perceive and what is going to receive touches and gestures from him/her.

Scenarios

The elements and interactions listed above will be encapsulated in Modules. This way, we will be able to reuse them.

Below we see how this architecture can be applied in an iOS project on two different scenarios.

Module with UI

In this scenario, the UI elements can be reused so we will include them inside the Module.

Alt text

Module without UI

In this scenario, the UI elements will not be reused so we will not include them inside the Module.

Alt text

Templates

There are 4 templates in this repository that will simplify the use of different scenarios. They can be found in the Templates folder and installed just by running the install_templates.sh, script that can be found in the same folder (permissions might need to be changed in order to execute this script (chmod command)).

The templates are:

  • NoUIScene.xctemplate: This template will create all the files and boilerplate code needed to create a new Module without UI.
  • NoUISceneTests.xctemplate: This template will create all the files and boilerplate code needed to create a new set of unit and functional tests for an existing Module without UI.
  • UIScene.xctemplate: This template will create all the files and boilerplate code needed to create a new Module with UI.
  • UISceneTests.xctemplate: This template will create all the files and boilerplate code needed to create a new set of unit and functional tests for an existing Module wit UI.

About

Skeleton of MVVM-C architecture modularised

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published