GithubHelp home page GithubHelp logo

nsviking / ios-clean Goto Github PK

View Code? Open in Web Editor NEW
1.0 2.0 0.0 269 KB

This project is a beautiful representation of an architecture with the CLEAN principles.

License: MIT License

Swift 99.29% Ruby 0.71%

ios-clean's Introduction

Random

This is an open project to show a way to implement CLEAN architecture on our iOS apps. There's not only one way to implement it so this is my approach. For that reason, I was inspired on VIPER, MVP and MVVM architectures. The most important is to take the advantages of each architecture and create your own view. In this project I decided to have a big dependency of RxSwift, it's an example of a common situation when you are the owner of the project and you need to decide which dependencies you have and which you want to avoid. But one thing for sure, working with tests is the most important, try to have tests for each layer and working with approach like TDD or ATTD. Because the tests give us a good perspective to build our architecture, meet the CLEAN principles and avoid lot of bugs in the future.

Exercise

This project use Moya (Rx Wrapper works with Alamofire as a Network Service client to obtain a list of users from http://randomuser.me, persist this obtained data on local storage with Realm, avoiding repetitions data. And render this data on a Master-Detail app, with a list of users and a detail for each one. Also have the posibility to search users by name, lastname or email.

Architecture

This is the best approach of CLEAN architecture for iOS. We have some layers to share the logic around, each layer has his own responsibility. You can see a visual scheme to understand better how it works:

alt text

  • View - Customize UI
  • Presenter - Presentation Logic
  • Router - Navigation layer
  • Interface - Business logic
  • Repository - Bridge between data and business logic
  • Client - Data layer, we can have DataBases, Network connections, Frameworks store, Memory, etc.

Tests

For each project the developers should decide what approach of test pyramid they need or they want to have. My favorite is an approach from the practical test pyramid of Martin Fowler:

alt text

At the moment this project only have the bottom layer, Unit Tests. But at one point I will add more tests for the other layers to show how can do it for iOS.

API Reference

I use a third party service to obtain the random user lists. You can find out more about this service on:

Random User

Installation

git clone 

cd /workdir

pod install

open Random.xcworkspace

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

ios-clean's People

Contributors

nsviking avatar

Stargazers

Omar avatar

Watchers

James Cloos avatar  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.