Code Monkey home page Code Monkey logo

modulardemo's Introduction

Modular iOS Application Architecture Demo Project

Sample Code from a Talk Held at the Cocoaheads Berlin October 2015 Meeting

An example how to structure an iOS application using modules.

When creating a modular system, instead of creating a monolithic application (where the smallest component is the whole), several smaller modules are written separately so that, when composed together, they construct the executable application program. Source: Wikipedia.

Design Decisions:

A Service Locator is used to decouple modules from their dependencies.

  • The Service Locator is a global dependency, but has only one interface. This makes the coupling not too bad and easily replaceable.

  • Resolving service dependencies should only be done in init(), causing it to work more like a dependency injection framework.

  • Configuration is only done once at application start, making it immutable afterwards and removing the need for locks.

  • Services are guaranteed to be available. Misconfiguration of the service locator is a programmer error, resulting in the application to “Crash Early”.

  • Dependencies should form a directed acyclic graph (without loops), mirroring “Clean Architecture”.

Regarding structuring dependencies, see “Design information flow” in WWDC 2014 Session 229: Advanced iOS Application Architecture and Patterns.

Regarding asynchronous modularization techniques, see “Subdivide app into independent subsystems” in WWDC 2012 Session 712: Asynchronous Design Patterns with Blocks, GCD, and XPC.

Note that for passing data across asynchronous boundaries (which interfaces can represent) it might be advisable to use some Future– or Rx–style library. Otherwise I would discourage most other global dependencies, since it tends to become a PITA fast.

modulardemo's People

Contributors

eikemeier avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.