Giter Site home page Giter Site logo

frankvalbuena / ios-clean-architecture-example Goto Github PK

View Code? Open in Web Editor NEW
68.0 7.0 16.0 706 KB

An iOS app designed using clean architecture and MVVM.

Swift 99.64% Ruby 0.36%
swift architecture viewmodel mvvm boundaries dependency-inversion-principle clean-architecture clean-code patterns

ios-clean-architecture-example's Introduction

iOS-Clean-Architecture-Example

An iOS app designed using Clean Architecture and MVVM. Each layer of the architecture has a Source Level Boundary, created with the Boundaries framework.

Description of The App

This is an example of an Appstore application, which fetches the data using the service https://itunes.apple.com/us/rss/topfreeapplications/limit=20/json, the data is stored locally on the app providing offline support. The app processes the data by categories with a UI that mimics the real app. This is an universal app showing the apps on a Grid for the iPad and on a list for the iPhone.

Architecture

The code is divided in 3 layers, Core, ViewModel and View. The Core is structured following the main premises of Clean Architecture. The app follows the dependency inversion principle using the protocol oriented approach that Swift has on its foundations. The app has unit test for each layer.

Core

On this layer belongs all the classes which main concern is handling the data and the high level rules of the app.

- Entities

On this group belongs the AppSyncData protocol which represents the data to be consumed by the app.

- Services

Services represents external agents like the web service used for getting the data and the repository in which data is stored, grouped and fetched. All the interfaces on this group are protocols, this allows mock objects to conform these protocols and being used for testing purposes on higher layers (like use cases and view models).

- Use Cases

The code in this layer contains application specific business rules. Each use case is represented by a protocol, the internal implementation is separated from the interface. Having a protocol per Use Case enforces the Interface Segregation Principle, facilitates unit testing and enforces the architectural boundaries. The use cases are accessed via a Boundary class . The objects on this group relies on the entities and the services via a plugin and returns the data using DTOs to avoid exposing the entity layer and to model the data in a convenient way to be consumed by the App.

ViewModel

The objects in this layer have the responsibilities described in the MVVM architectural pattern. The ViewModels relies on the UseCases to get the data and model in a convenient way to be shown in the UI.

View

The objects on this layer are the UIViewControllers and the UIViews used to present the data to the user. The view controller binds the data from the ViewModels to the UI objects, for tracking changes simple closure are used. This project doesn't include any binding framework to keep this as simple as posible and avoid coupling the layers with any reactive code.

License

MIT License

ios-clean-architecture-example's People

Contributors

frankvalbuena avatar frankvalbuenam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

ios-clean-architecture-example's Issues

Couple of questions

Hi, I really liked the architecture used in this project, I just have a couple of questions I was hoping you could answer me.

In many places you use type(of: self) to access static constants, whats the reason or advantage to declare those as static and not just a let?

At the ItunesWebService class you parse the data you receive from the request, but you are accessing the data through key value. Any reasons to not be using Encoding/Decoding? And if it could be used, how would it work?

You only have one entity AppData, in a more complex application would you have many entities? For example, a User entity, Product entity, Department entity, etc. And if so, would this cause any major changes in any part of the structure?

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.