What did I learn about Android Development in 2018
In January I started working for a Diabetes Care startup called Diasyst where I joined the Android development team. It was my first contact with such a high level organization and as I make retrospection through the past 12 months I can’t help but be grateful about the things I learned in 2018.
Having a clean approach is a must in every project.
When I started developing Android apps back in 2014 like everybody else I would put everything about a screen in one class. This is the so-called God class approach (God Activity approach in Android). It’s called that way because there is one single class that is responsible for everything that a screen has to handle: fetching the data from backend and/or from a local database and displaying it on the screen in an user friendly way.
Although the code was working fine, when I had to come back to a class that I had not worked on in a month I would always hate myself because of writing it. The screens would usually have 1500–2000 lines of code. And in order to add a new feature or fix a bug, I would have to go through all of those lines to make sure that I’m not breaking anything else. It was a big messy hairy blob of spaghetti code!
Back in 2014, there was nothing mentioned in the official documentation about architecture. Google were silent so if you wanted to use a clean approach for building your app, you had to dig through a lot in order to find that.
As the years went by, I started following the Android Development sub in Reddit where I got exposed to the newest trends and best practices. In 2015 and 2016 the community was mainly using Model-View-Presenter (MVP) for an architecture and in the last two years it swinged to Model-View-ViewModel (MVVM). There’s not a lot of difference between those MV* architectures, as all of them are teaching the developer to seperate the UI from the business logic(the ViewModels or the Presenters). I started implementing those architectures in my projects and started seeing how my 2000-lines of code screen classes got divided to several classes where each of them got a distinct function.
In 2018 with the Android development team at Diasyst we implemented our version of a clean approarch MVVM with a distinct seperation of the presentation, domain and data layers. I got to build the login and register feature which consists of about 25 screens and can say that the code is now very readable, testable and maintainable which were the things we were looking for.
In bigger teams that is essential as the newer developers can easily get a hold of the project just by understanding the architecture the app is written in instead of having to untangle the spaghettis.
Tests are important
Ever since I started development, I always had that guilt in myself when developing new features that I may break something else. So after checking if the new features works well, I have to go through the other features to make sure they are still working.
As I learned about the different clean architectures, I was initially fascinated by the code readability and that was the reason I started implementing it in my work. In the past year though I learned the importance of having tests set in your project. Although the time of developing a new feature is bigger now, the confidence that the tests are giving me is something I don’t want to get rid of. For now I’m only using unit tests but for 2019 I want to learn the other types of tests as for me code quality is essential.
I love doing this!
There’s this quote I heard when I was in high school:
Choose a job you love, and you will never have to work a day in your life.
Back in high school, when I was in my final grade, when all of my schoolmates had already chosen what they were to study I still was not sure what I wanted to do for a living. I always thought software engineering was cool but I was not sure I’d enjoy having to stare at a computer screen for 40 hours a week.
I went to uni and started programming and maybe I never had the time to reflect on that before but through the past few months I realized that I actually love my job.
I was working on the Android version of a simple white noise app called Baby.Soother. It is a side project we worked and I got the freedom of using the newest and shiniest tools in the Android Development. When those were added to the engineering part of implementing a clean architecture and having tests set in the project, that resulted in me getting excited every morning about starting to work on that project. And that’s something I’m very grateful for.
I started writing this post mainly as a self-reflection journaling for the past year. If you, dear reader, have reached that far, I hope you’re going to have a very joyful and blessed 2019. :)