If you can't be bothered to read, scroll down to the TLDR at the bottom of the page.
I'll let the app speak for itself first.
So it's just FizzBuzz! You enter a number and you get the FizzBuzz-ified version back.
I know what you're thinking, this is simple. You could probably write this in 30 minutes, it's a layout file and a single 100-ish line Java Activity.
Of course, this simple app is more than meets the eye. Quite clearly inspired by FizzBuzzEnterpriseEdition, this application is an extremely contrived example for using popular/trending/fancy Android development techniques and tools.
Instead of the aforementioned 100 lines of Java, this project is ~1000 lines of code spread across ~30 files and many packages. But it's all for good (?) reason.
And all those lines aren't even Java's boilerplate, because the entire app is written in Kotlin to practice (and perhaps promote) the language.
Kotlin is a really nice language for the JVM created by JetBrains and you can learn all about it on the official website.
The app is built with Clean architecture, more specifically along Marko Milos's interpretation of it. You can watch the very underrated presentation he gave about it at droidcon Zagreb 2016 on YouTube here.
Here's a high level overview of the architecture from their presentation - it's fairly close to most Clean architecture implementations, and it uses MVP for the presentation layer. Watch the presentation linked above for more details.
And here's the presentation layer's MVP structure, base classes with green, concrete classes with blue, external dependencies in white.
In the project you'll find classes prefixed with Buzz
instead of Example
, as this diagram is meant to be more general.
The project contains 3 modules:
- app (Presentation layer)
- views, presenters
- domain (Domain layer)
- use cases, repository interface, (business logic would go here)
- data (Data layer)
- repository implementation, data sources
- RxJava: Reactive programming is getting more and more popular in every language and on every platform, and Android is no exception, so it would be a shame to miss out on it.
- RxAndroid: Mandatory addon to the previous library, provides Android specific schedulers.
- RxKotlin: Kotlin-friendly extensions for RxJava.
- Anko: The definitive Android library for Kotlin, with many utilities, generally making life easier.
- Dagger 2: The go-to dependency injection framework.
- Retrofit: Network communication library by Square.
Yes, although it's not what you might think, the app isn't phising for your personal information.
What it does do is use buzzcloud.xyz's REST API. This wonderful websites offers free FaaS (FizzBuzz as a service), and thus provides the application's business logic.
###Tests
The project has just a couple of them, since most classes are just simple passthroughs and the REST API does not need testing. The tests use JUnit, Mockito, and Mockito-Kotlin (which provides some more Kotlin-friendly syntax for Mockito, although the parts of it used could easily be reimplemented).
The following tests are included:
- Presenter
- Repository implementation
- Memory data source
- Higher level tests
This is a simple FizzBuzz app that has/uses:
- Kotlin and Anko
- Clean architecture with MVP (in separate modules by layer)
- JUnit tests
- RxJava, Dagger, Retrofit, Mockito
- a REST API for the business logic