This template is one I have named I-VIPER, and you could also see it such as:
- JAVAT: Just another VIPER architecture template
This architecture was created from the union of different resources, but, I think the most involved resource comes from The.Swift.Dev.
You can see through his page a lot of VIPER related articles.
The Ultimate VIPER Architecture tutorial
I don't want to dig deeper in what VIPER is, there is a lot of great resources around internet that have well-explanations of it.
But basically it is an architecture that helps to decouple layers and see our features as modules, instead of Controllers
.
Remember there is no a final rule!, this is just a guideline that you could adapt it to your needs.
So let's give a short summary
I recommend you to take a look to The.Swift.Dev article, this is going to be a short summary of it.
VIPER architecture is one of the most popular architectures to write scalable and maintainable software.
Some people like it, some other don't, anyway, it will depend on each developer/team.
VIPER architecture is conformed through these layers.
View
The View
usually is mostly conformed by UIViewController
(or related) subclasses.
The idea is to don't have any business logic in here, it is in charge to just present and catch events.
Interactor
The Interactor
's job is to retrieving data from the model layer, this can prepare and transform the data that you get from a database or a service.
DataBases and Services are not part of VIPER so they are treated as separate components, the best practice is to use DI (Dependency Injection) to handle this.
Presenter
The Presenter
is responsible to format the data that is going to be displayed, also because it is connected to the View
it also works as an event handler.
It is the CORE of VIPER because it connects with the Interactor
and the Router
.
Entity
The Entity
is a plain model class mostly used by the Interactor
, basically your model.
Router
This is the navigation logic, it also prepares the view.
Another good practice in
Router
is to use aBuilder
to decouple responsibilities to the router, use the builder to build your view and router just to navigate.
Now! How to use these templates?
Installation
The installation of these templates is really easy, you just need to use your terminal and locate yourself to the folder that you download from I-VIPER | fdorado985 | GitHub
The main image at the top is also a link to this repository.
A quick shortcut is to just type cd
(change directory) command on your terminal and a space (don't forget the space), drag and drop your I-VIPER folder and press enter.
Then just run this command
make install_templates
Once installed, you can use them in your project.
How to use
You just need to create a New File
and look for Module
in the I-VIPER
section you installed before
Give the module name, and which subclass do you want to use from the three available in there.
And if you want or not to create an entity for your module.
Quick Fix
Unfortunately the module created is added as reference folders (or virtual folders)
As a quick fix for this, you can just remove the reference and add it from your finder, be sure you have the creation by folder groups and copy if need it options checked.
And there you go! you will be more productive without being repeating a lot of boilerplate code!.
And repeating what I said, this is a guideline, even you can use it and adapt it to your needs, if you want to improve this template feel free to pull-requested and we'll see the improvement!.
Thanks for the reading and 👩💻 happy coding! 👨💻
Top comments (0)