Android Clean Code — Part 5 — Configurator & Scaffolding

Learn more about the Clean Code Android mobile design pattern and unit testing your Android app piece by piece for code quality.

Mohanraj Karatadipalayam
2 min readAug 1, 2017

Having understood Android Clean Code, you must have worried about writing the classes and wiring the dependencies yourself.

Wiring the dependencies must be done carefully otherwise you end up creating circular references — in other words memory leaks.

Who does the wiring of the Interactor, Presenter, Router and the Activity classes ?

Configurator.

Let’s look at the configurator code.

The code is straightforward. Why WeakReferences ?

We should not have any strong references of Activity classes from Router and Presenter, otherwise Activity will never get released from the memory.

Due to single responsibility principle, we have many classes and effectively, yes, too much boilerplate code.

Don’t worry — Android Clean Code Generator solves all of above mentioned issues.

We have created a tool that will auto generate the code and wire the dependencies. All you need is to clone the project and import the project in Android Studio.

Where to import?

  • Windows : Navigate to the location of the templates folder :
    cd {ANDROID_STUDIO_LOCATION}/plugins/android/lib/templates/other/
  • MacOS: Navigate to the location of the templates folder : cd /Applications/Android\ Studio.app/Contents/plugins/android/lib/templates/other/

Finally, restart Android Studio — It should work with out any issues.

How to use?

File → New → Other → Android Clean Code

Android Clean Code Generation

This code generation project ideas aren’t new in any way. Credit has to be given to the following projects, listed below.

clean-swift

Make your own File Templates in Android Studio

What’s next? We’ll talk about “Implementation and After thoughts” in the next post.

Thanks for reading this article. Be sure to click ❤ below to recommend this article if you found it helpful. It means a lot to me.

--

--

Mohanraj Karatadipalayam

Polyglot developer, Engineering manager for iOS and Android apps, Amadeus Labs