Chaos and hope in the Android world

Beginner thoughts and advice

Should I start with the good, the bad or the ugly? Hmm, I know! I will do it with no order, it will be chaos, like Android development! That is how I felt sometimes but here me out, there are things you need to know before judging Android.

Android is not a framework, it’s a platform

I come with some experience with javascript, the land of frameworks and ui libraries. Frameworks are useful when you want to create an application. It often comes with a set of guidelines, directory structure and rules that makes your code clean to write and read. You don’t spend a lot of time thinking about the how, you just do it.

For some reasons, I expected Android to provide me with a set of best practices, basic directory structure and guidelines on how to build a scalable, large application. Like everything, I come to like the things I hated before. Not having rules allow you to explore different possibilities. It forces you to think by yourself, what does work best in this situation, in your opinion?

Welcome to the world, there are no rules. Do what you want and have fun!

But it also forces you to spend time looking at problems thousands of people already asked themselves. And believe me, sometimes finding the answer is difficult. It is frustrating to spend a few days exploring the different way developers organise their Android project, instead of coding. Why are you doing this, you ask. Well, I kind of want everything to be perfect right away, I should work on that. Let’s talk about something I don’t like:

Coffee

Java is a verbose programming language, it is probably not something to argue. Be prepared to scroll. A lot. But there is a solution: Kotlin. Some articles will introduce Kotlin better than I can do but let’s just see a quick comparison.

Left: Java ; Right: Kotlin

I should have put a gif so you can see the entire java class. Ok, I pushed it to the extreme but you get my point. This leads to the following problem. What you would consider to be a simple functionality can required multiples files of 100+ lines of codes. There is a solution for that. Android Studio templates. Android Studio comes with this features, templates. With it, you can create boilerplate code and add it to your code easily. But it is unfortunately not exploited to its full potential. PS: I am not talking about snippets.

Lack of information

Have you seen the website for the material design specification. Impressive, isn't it? You have everything, the dimensions of the buttons, of the margin, the color palette, etc… Material design has been introduced in the same time as Android 5.0 Lollipop. I always thought it was well integrated in Android. Surprised! It is not. An example to illustrate what I mean:

In March 2016, the bottom navigation was introduced to the material design specification. The specification is perfect, with example of animation, usage in an application, dimensions and all. Some of Google applications feature the bottom navigation. Perfect! I will be able to use it in my layout, it is probably hidden in android support library? Nope, it is not available, you can’t be aware of what is available easily, either follow the blog or maybe the twitter of Android developer or you have to look on Google to see if what you are looking for is available. I feel like having a comprehensive list of what is available is not a big thing.

I read this open source story recently and this sentence make me think of that problem.

Building cool things and adding features is awesome, but if no one understands how to use said features, it is kind of pointless.

— Jess Frazelle

Good documentation is something we all need and care about. A lot of framework have open source documentation, meaning that someone can improve the documentation if he sees a need of it. Take a look at Android developer guide, you have to download the zip file to take a look at the complete code. Do not expect the code to run on your phone, it will not work, some library are missing. The simple solution to this problem is to put the code and documentation to Github. Microsoft took this path not long ago with .Net documentation. The maintainers of React are calling to developers to improve their documentation, recognising the possibility of improvement.

I believe the official documentation should be enough to get you started. And Android documentation is indeed enough to get you started, but you are not going to get far.

And unfortunately, even the official documentation has problems. When you read the guides with the examples provided, you can not forget the verbosity of Java. The entire code is split in 8 parts across the page and you can’t see the entire project. It is difficult to read and understand. All that to get the list of contacts.

The community

The Android community is great. I talked about some of the problems I have encountered. Problems such as the lack of documentation, the lack of information, the lack of guidelines. Guess what? The community acted, did something about it, it is partially hidden and I had to look to hard to find it but there it is:

Hope

If you manage to read all the above, you should know that I actually wrote that a few month ago. I went back to the Javascript land and went away from Android, taking quick glances at it from time to time, wanting to get back to it in my free time. Today, Android announced the support of Kotlin. And with this news, it is telling the world that Android is not dead. Android is a modern platform that can be a rival to Ios and Swift, to Javascript and React Native and others. And that is why I will not let it down.

Android support Kotlin (modified Android Studio logo)

Software Engineer and author of PurgeCSS — Writing articles about web development regularly