-
Notifications
You must be signed in to change notification settings - Fork 15
Architecture and Structure
This page provides an overview of JenkinsiOS's architecture and structure. Please feel free to refer to the source code or send us an email for further inquiries.
When opening the project in Xcode, it becomes clear that it is organised into four parts that reflect their place in the MVC design paradigm. The project is organised into:
- Model
- Controller
- View
as well as
- Services
The classes in these categories are mostly self-explanatory, as they have direct counterparts in the user interface. Since this application makes heavy use of UITableViews, two wrapper classes: BaseTableViewController as well as RefreshingTableViewController have been created to take care of the most common tasks.
The first view controller that is presented when opening the app over the home screen is AccountsTableViewController. From there on, it is a mostly hierarchical structure of view controllers that is very well displayed in Main.storyboard.
Quite a few classes belong to this category. All classes that represent model objects from the Jenkins API can be found in the Jenkins API subgroup. Most of the classes that represent those model objects have initializers that set them up from given serialised JSON data. The other classes - UserRequest, Account, ApplicationUser, Favorite as well as Favoritable - are model objects that are needed for the app to do its work.
A UserRequest is the model class that many NetworkManager methods need to function properly. A UserRequest encapsulates the data needed for a network request to happen (namely the account that should be used for that request). In that function, a UserRequest does very little to no computation on its own.
An Account represents a given Jenkins instance and any information that is relevant for using that Jenkins instance (such as the user's credentials). Again, an account does no computation on its own. Accounts are managed by the AccountManager service.
ApplicationUser represents the current user of the application with all of its Favorites. There can only be one application user at a time. ApplicationUser is managed by ApplicationUserManager. The current application user contains relevant information for that user (such as how many times the app has been launched by the user and if he has been asked to review the app yet).
A Favorite is the representation of a job or build that conforms to the Favoritable protocol. A user can have multiple different Favorites that in turn represent jobs and builds from different Accounts.
JenkinsiOS makes heavy use of services that are supposed to take simple model objects and transform them or provide other model objects. The most important services are: NetworkManager, AccountManager as well as ApplicationUserManager.
This singleton handles all network-related tasks. Every request that the app should perform (such as fetch all jobs) are handled by NetworkManager methods. In these methods, the raw request is made which is then transformed into the fitting model objects. Those are then handed back into the provided callback. Most NetworkManager methods also return a custom URLSessionTask wrapper: URLSessionTaskController.
This singleton handles all account-related tasks. Mainly, it is tasked with persisting the accounts as well as adding new account and deleting existing ones. The accounts are persisted using NSKeyedArchiver as well as the Keychain for user sensitive data. On creation, the AccountManager then reads that data and creates account objects.
This singleton handles all application-user related tasks. It saves the current ApplicationUser and is tasked with persisting it to disk.
Created by MobiLab Solutions GmbH.