Code Monkey home page Code Monkey logo

card-games's Introduction

kotlin-template

Kotlin Clean Architecture Template Project. Uses dagger2 for dependency injection yall

Projects using this architecture:

  • warningapp-kotlin-android
  • dfds-channel-android

Live Templates

The Kotlin template comes supported with a its own set of live templates which can be found at

https://github.com/nodes-android/androidstudio-livetemplates

It should make generating the boilerplate for activities and fragments easy.

Nodes Architecture Library

The Template uses components from our Architecture library so be sure to read up on how that is used as well

https://github.com/nodes-android/nodes-architecture-android

Below information might be slightly out of date

Layers

This is a 4 layer onion architecture. Dependencies are only allowed to point inwards, meaning that the inner layer most not reference code in the outer layers directly. From inside out it consists of:

Entities

Models/POJOs implemented as data objects in kotlin.

Business Logic / Use Cases

Consist of interactors and repositories (the interfaces). The interactors encapsulates the business logic and perform operations on the entities. Interactors are scheduled to run in the background and return information to the outer layer through callbacks implemented in the outer layers.

Interface Adapters

ViewModel (as part of the MVVM pattern) are implemented in this layer. ViewModel holds information from the inner layers (business logic and entities) to the user interface etc. In other words they adapt the data for output to the outermost layer (Framework and Drivers)

Frameworks and Drivers

This is the outmost layer consisting of things such as the User interface (for android Activities, fragments etc), database libraries, retrofit, okhttp etc. This also contain specific implementations of the Repository interfaces the business logic layer needs to access data.

Flow of control

Example:

  1. User clicks a button that loads a list of posts in a view.
  2. OnClickListener executes a Interactor/UseCase asynchronously in the business logic layer.
  3. The Interactor runs in the background accessing a post repository which fetches a list of posts
  4. ViewModel gets notified with the loaded posts or a message in case of error trough a kotlin.Result callback
  5. ViewModel updates a MutableLiveData(Facade pattern) with the new data, or display an error to the user using the same MutableLiveData pattern

Patterns in use:

  • MVVM
  • Repository
  • Interactor (implemented with a pluggable dispatcher)
  • Dependency Injection (and thus factory)
  • Inward dependency rule (all dependencies must point inwards)

Stuff

  • kotlin data classes as entities
  • Retrofit2/OkHttp3
  • Android kotlin extensions (views are automatically made into properties on the activity)
  • Uses nstack-kotlin
  • Mockito and junit for testing

Inspired/partially ripped off from the following sources:

card-games's People

Contributors

johsoe avatar biscon avatar brianestrada avatar vovahost avatar cramer86 avatar thsknodes avatar

Watchers

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