Code Monkey home page Code Monkey logo

openmovie's Introduction

openMovie

Maintainability CI codecov

Show case Android practices using the Movie db

                 

Tech stack

  • 100% testable Kotlin code
  • Clean Multimodular Architecture
  • Presentation layer built based on Unidirectional data flow (UDF) and single entry points
  • Latest AGP 7+
  • Dagger Hilt
  • CI with Github actions
  • High test coverage using Unit, Instrumentation and Integration tests

Architecture

Multi modular project structure

Architecture This project aims for showcasing a multi modular architecture based on 2 concepts: Libraries and Features

  • Features contains all user facing functionality (e.g. Discover, Movie Details)
  • Libraries are shared modules that help the building of features (e.g. network, ui, test)

Feature architecture

Each feature is developed using clean architecture composed by 3 layers: Data, Domain, and Presentation. Domain is completely independent of the other layers and both Data and Presentation depend on Domain. This inversion of dependencies guarantees scalability, easy maintenance and testability of the code. Clean_architecture

Feature Presentation Design Pattern

Features are designed following the Unidirectional Data Flow (UDF) principle in conjunction with the Model-View-View-Model pattern

The UDF pattern guarantees predictability of the code which also makes the code much easier to test. These concepts come from the REDUX framework from javascript

In this project, we use the following structure in order to implement UDF

  • The state, the source of truth that drives our feature;
  • The view, a declarative description of the UI based on the current state
  • The actions, the events that occur in the app based on user input, and trigger updates in the state

UDF

We can take the following as an example of UDF:

  • State describes the condition of the feature at a specific point in time
  • The UI is rendered based on that state
  • When something happens (such as a user clicking a button), the state is updated based on what occurred
  • The UI re-renders based on the new state

CI

In addition to static analysis and unit tests we are using a test matrix for each commit on master. and triggering all instrumentation tests for different API lvls

Testing strategy

Data Layer

The data layer is tested through a combination of unit tests + Mockwebserver in order to fully test Retrofit network integrations. By following this approach we are covering:

  • Retrofit instance
  • Json converters, in this case Kotlin Serialization converters
  • Network data sources

The main idea is to make sure that the whole network integration is working before starting to implement other areas of the application.

I've wrote an article explaining how this works in more depth

Domain Layer

For the domain layer the tests are standard unit tests focusing on outcome not implementation and using the correct test double for each case. Avoiding unecessary mocking of classes is proven to make unit tests faster. There's a good article about when to mock from uncle bob here

Presentation Layer

Finally the presentation layer is tested using the following strategy

  • Unit tests for VMs and mappers. Here mocks are used to cover the architectural boundaries (VM and Use cases)
  • Instrumentation tests for UI and integration. For those types of tests, the approach used is based Testing Robots

openmovie's People

Contributors

dependabot[bot] avatar horowitz 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.