“Light” iOS Architecture Pattern
This is a personal design pattern i’ve created , after reasonable years of IOS mobile application development at Hubtel Limited .This approach is suitable for mobile applications which depends massively on web services.I call this a simplified combination of Viper and MVC design patterns .
Many design pattern are out there ,and majority of them are somehow difficult to understand or use, some are restricted to Large projects and others to small projects ,but light pattern architecture has no restrictions, it speeds application development and debugging.
There’s probably no truer statement in software engineering.
A Test engineering manager must be diligent about identifying the best practices happening in their organisations and be aggressive about communicating those practices to their peers.There is no truer way to show that a practice or tool is impactful than to see it applied successfully to ,multiple products ~How Google Tests Software.
You may ask what defines a good software architecture ?
- A Balanced distribution of responsibilities .
- Testability .
- Ease of use with low maintenance cost.
- And many more . check this link
Below is the Architecture Break down

Features in this Pattern are classified as Modules we will examine a feature which connects to a web service to make a simple mobile money payment, we can call this feature Mobile-Money-Payment-Module .I will use this simple project to describe this light architecture .
We will be using the following libraries
1. SwiftyJSON : The better way to deal with JSON data in Swift.
2. DISK : A delightful framework for iOS to easily persist structs, images, and data
3. SnapKit: A Swift Autolayout DSL for iOS & OS X
1. Setting up the Project in Xcode and Creating Group Folders .

First of all, we create a Project in Xcode and also create a Group Titled Momo Module with 4 sub groups. as seen in the adjacent image.
1.1 Expanded Groups with Sub Module classes

We can now continue to define the modules classes in the Group and sub groups with corresponding classes as we see in the adjacent image.
1 Since we won’t be Using StoryBoard we must configure our AppDelegate.swift to detect our main view controller.
In the AppDelegate.swift class update the didfinishLaunchWithOptions function.

There are some few important steps which needs to be noticed in this pattern ,you can however get the full project here
1. The Manager class MomoManager.swift

The Manager class first of all must define its manager protocols on top of it ,these protocol methods will act as messengers between the Views,Webservices lifecycle and any other utility method , We Strongly recommend that ,all major functions in a module should de described in the manager class,
The manager class goes ahead to extends the WebServiceDelegate which receives information from the Webservicer , processes and communicate responses to views or classes which has inherited it .
2. The WebService Delegates WebServiceDelegates.swift

This protocol class contains functions which will be used to monitor any webService call , Any manager that will be consuming webservices should extend this protocol,you can define protocol functions in this class based of the module.
3. The Web Service Dispatcher class WebServiceDispatcher.swift

The Webservice dispatcher class contains 2 functions, requestBegan func ,which notifies the manager class via a web servicer delegate that a particular module webservice call has began ,the requestDispatcher func,which processes response from a webservice and informs its managers via its delegates.
3. The Webservice class Webservice.swift

We can see that, before the class definition we have a struct URLString and an enum RequestType ,these are custom variables i use to tag my Webservice calls.

The makeCall func is a general function which takes a URLString ,Headers ,httpMethods,parameters and a web service delegate protocol class.The URLString contains a Request Type which helps the WebService Dispatcher to detect which request was made.

The PayMomo func is where i define the URLRequest variables and also construct my custom URLString variables to help me track my requests to web services , i pass the request parameters to the makeCall general function which with the help of the service Dispatcher tracks the request life cycle and distributes to other classes which have subscribed to its delegates
4. The MomoPayment Viewcontroller MomoPaymentViewcontroller.swift

In the MomoPaymentViewcontroller right above the viewDidload function , the Momomanager is initialized and also the views class extends the MomoManager delegate protocol ,by doing this the view submits to the MomoManager class to control it. To initiate a mobile money payment i just have to setup the functions in the manager class and transfer responses via the MomoManagerDelegate to any view of class listening to it .

And then i can initiate the request from the View class by help of the manager variable

This is simple and sweet ,you can check out the full project from this repo and enjoy ,https://github.com/yawboafo/LightDPattern.