Skip to content

Improvements on best practices

Kaustubh Patange edited this page Aug 13, 2020 · 2 revisions

Yes you heard right

Wait what?

Although this app is built using Architecture Components, there are some patterns that are implemented in the wrong way. Some of them are listed below:

  • There is no sealed class Result<T> which should be used to along with viewModel to present changes to UI.
  • Lot's of unnecessary switching to different Dispatchers for doing different jobs.
  • Lack of viewModelScope in viewModels.
  • Most of the logic is put in viewModels instead of the repository to handle them.
  • No separation of remote & local repository.
  • Lack of use of suspend modifiers for doing async tasks.
  • Use of Flow<T> in lower level instead of LiveData<T>
  • Lack or maybe no tests
  • Lot of more...

But why they are still there?

This will take me back to when I started learning Kotlin for the Android first time & I was pretty naive as this was my first app which was built with it, obviously day by day I was increasing my knowledge in this field and was just started out to follow best practices. I was still making mistakes (we'll do I guess).

I used to implement what I learn in this app, but something got me stopped for about 2 month due to which this app's work was pending. I was still here and there doing some small changes, but I know it was not enough. When I learn about all my mistakes and what should be followed I was late and the app had a solid concrete structure which would take me months to refactor.

I'm not saying it is completely spaghetti code, it is readable, understandable, maintainable & most important working. What I'm saying is I know there are some rules or pattern which are followed wrong or maybe not wrong but they've changed over time.

The app has still refactored a lot to see where I can fix some of these implementations. I'll do my best when I find time to refactor the code to meet the new best practices.

Clone this wiki locally