iOS architecture transition

From CornerJob iOS Team we designed an architecture transition that allowed us to continuous delivery of new features to product and allowed to improve the code development, maintaining compatibility with legacy code and backend.

The different phases were:

  • Initial phase: No plan, hell architecture.
  • First iteration: Create models, analyze business logic, different layers, …
  • Second iteration: Create Interactors, Repository, data sources and unit testing. Implement cache system explained at the meetup about Mobile backend as a service.
  • Third iteration: Swift and Reactivity.

Initial phase

  • Legacy code without architecture or hell architecture.
  • Code strongly coupled to Parse SDK.
  • No test, 0% code coverage and QA manual
  • No network layer.
  • No local storage layer.
  • Too much code on static classes.

First iteration

  • Create uncoupled models without dependency on any SDK. Now models can live together with another providers at the same time. It’s easy add or remove providers.

  • Move the business logic from view controllers and static classes to models.
  • Create network layer that supports different providers.
  • Create local storage layer that let us use any provider (CoreData, Couchbase, Realm, ..). In our case we use Realm.
  • Schedule the cache system road map.

Second iteration

  • Move the business logic from models and view controllers to interactors. In this point we add unit test to our business logic.
  • More than 650 unit testing and 15% of code coverage.
  • UITest with our own framework.
  • Create Repository (CRUD) singleton object by entity.
  • Create data source manager with all the meetup talk logic. This data source pass to repository which (network, local storage, cache) should be used to execute the operation.

To make possible this diagram we need some kind of class with the configuration of the request.

This class is easily testable and doesn’t need too much code.

Third iteration (WIP)

Implement MVVM using Swift and Rx to disconnect different components and make it reactive. In this phase we use Objective-C for our core and we will implement view models, views and view controllers in Swift.

Alex Martínez

Read more posts by this author.