Loading...
Home
  • Tech Blogs
  • Videos
  • Conferences
    • Droidcon News
    • Upcoming Conferences
    • Become a Partner
    • Past Events
    • Keep Me Informed
    • Diversity Scholarships
  • Community
    • droidcon Team
    • How to Hold a Droidcon
  • Android Careers
Sign In

Global CSS

 

Android Legacy Codebase Refactoring

 

 
Kumar Gaurav
Senior Software Engineer 1 @Citrix | Passionate about learning and sharing knowledge | https://github.com/kgaurav23
Published: July 22, 2020
Tweet
Share
 
Why we need to keep modernizing the app

 

 

“I’m not a great programmer; I’m just a good programmer with great habits.” — Martin Fowler

 


When we talk about refactoring the code, the very first thing which comes to mind is that “Why to change something which already works”. We often convince ourselves by telling that we should focus more on fixing customer issues, adding new requirements/features as this is the area from where actual money comes in. While we focus on making customers happy, we often forget the other side of the coin which is to make developers happy as well since they are the one who has to work on that codebase for many years. And we all have felt this pain while debugging a bulky, lengthy and tight coupled codebase.


There’s one modernization practice which we as an android developer adapt every year without fail. Yes, you guessed it right! It’s target API level requirements which have been made mandatory by Google since November 2018. Targeting to recent API level ensures that users get to benefit from significant security and performance improvements. While we do this transition religiously every year, we often ignore to adapt other platform features which can make both users and developers happy. Let’s see below what I mean by this.

 

Image for post

 


What makes our users happy ?

  • Dark mode support: Dark mode is probably one of the most popular features in the modern user interface. From apps to operating systems, Apple to Google, smartphones to laptops, many of the products we use today have some type of dark mode integrated into the user interface. Not only it is good for our eyes but also it saves lots of battery consumption. If we don’t choose to modernize the app by implementing dark mode support in the app, users gradually would start to avoid using the app at all.
  • Latest UI widgets and animations: Users want to have a consistent experience while browsing apps in their devices. If they see any deviation in any app, it might be a little annoying to them. Today most of the apps use various material design components combined with proper animations which bring newness in look and feel of the app. Imagine users open your app and see very old and outdated UI widgets, it might cause a turn off and they might start looking to find a better replacement for your app.
  • Multi-Window and Picture-in-Picture support: Modern users love to multitask throughout their day. Adding support for multi-window and picture-in-picture will increase productivity and improve user experience a lot. Although not having these features might not be as bad as above mentioned features but at the same time, it adds lots of value if implemented correctly in the app.

There are many other such examples which we can adapt/implement in our app to make it look modern with time so that we don’t get left behind. Now, let’s see how developers can benefit from modernizing the apps regularly.


What makes our developers happy ?

 

Image for post

 

As Martin Fowler said in his Refactoring book:

 

“When you think about programmers, most of us will think that they spend most of their time writing code. Actually, this is quite a small fraction. Programmers spend most of their time reading the code and debugging it. Every programmer can tell a story of a bug that took a whole day (or more) to find. Fixing the bug is usually pretty quick, but finding it is a nightmare.”

 

We can clearly see the importance of well-written code as it’s easier to read and maintain. Let’s see what are various ways which we as an android developer can adapt to make our life easier.

  • Start using Kotlin: Developers around the world want to write as least code as possible and still achieve their objectives. Kotlin helps the developer to write better apps faster and with less code. Since it’s fully compatible with Java, you can start using Kotlin in your app from today. Let’s see some advantages of using Kotlin below.

 

Data class makes code concise and easy to read

 

Kotlin way of handling NullPointerException

 

  • Use Jetpack components: Jetpack is a suite of libraries which help developers follow best practices, reduce boilerplate code, and write code that works consistently across Android versions and devices so that developers can focus on the code they care about. These libraries make day to day life of developers very easy. They take care of managing activity lifecycles, survive configuration change (major pain area of any developer) and help to prevent memory leaks in the app. So now developers can focus on implementing business logic and leave other important details for android to handle.
  • Consider using CameraX: Whoever has worked on camera APIs earlier knows the pain point of using it. Developers needed to take care of the lifecycle and add device-specific code in the codebase to resolve device compatibility issues. And even after investing multiple hours in development, we never used to get the same experience which preinstalled/native camera app provides. So Google has come up with CameraX library (part of Jetpack) to make development easier. It provides a consistent and easy-to-use API surface that works across most Android devices.
  • Be flexible in adapting new app architecture: Don’t shy away from adopting a new architecture if it suits your requirement in a better way. The thing about architecture is that it doesn’t last long and it changes frequently with time and requirements. So always be proactive on this front. I had recently written an article about switching from MVP (A famous app architecture once upon a time) to MVVM (Google recommended app architecture), you can read it here.

Now that we have seen multiple examples of modernizing apps which make users and developers both very happy, I’m sure most of you will start thinking towards implementing some of them in your codebase starting today. Don’t wait for a perfect time to start refactoring/modernizing your apps as you might almost never get time to do so. Build a habit to make incremental change daily and you will see its results in no time. Don’t wait for something to get broken to implement the change, but take proactive actions and update before it gets old.

 

 

 

Tags: Android, Refactoring, Modernization, Best Practices, Kotlin

 

View original article at: 


 

Originally published: July 04, 2020

Android News
Evolution of Android Update SystemEvolution of Android Update System
Evolution of Android Update SystemEvolution of Android Update System

By Ivan Kuten

So, how can you update Android on mobile devices? While developing software for Smart TVs and Android-based set-top boxes, we’ve narrowed it down to four ways, discarding some very exotic options:

By ProAndroidDev -
Android News
Happy Railway
Happy Railway

By Hadi Lashkari Ghouchani

This post is on the tail of Railway Oriented Programming in Kotlin by Antony Harfield. So you need to read it first and continue here. As it’s obvious I really liked it and tried it out. It needs every process have a result like

By ProAndroidDev -
Android News
Unit Tests and Concurrency
Unit Tests and Concurrency

By Stojan Anastasov

Once Retrofit added RxJava support, RxJava became my go-to concurrency framework for writing Android apps. One of the great things about RxJava is the excellent testing support. It includes TestObserver, TestScheduler, RxJavaPlugins so you can switch your schedulers in tests.

By ProAndroidDev -
Android News
When Compat libraries will not save you
When Compat libraries will not save you

By Danny Preussler

And why you should avoid using the “NewApi” suppression! The idea of “Compat” libraries was probably one of the key aspects of Android dominating the mobile space. Other than with iOS, Android users often could not update their operating system after a new version launch, simply as their phones won’t allow them to, the Android problem of fragmentation.

 

By ProAndroidDev -
droidcon News

Tech Showcases,

Developer Resources &

Partners

/portal/rest/jcr/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/home-details/EmployerBrandingHeader
EmployerBrandingHeader
https://jobs.droidcon.com/
/portal/rest/jcr/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/jobs-droidcon/jobs.droidcon.com
jobs.droidcon.com

Latest Android Jobs

http://www.kotlinweekly.net/
/portal/rest/jcr/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/kotlin-weekly/Kotlin Weekly
Kotlin Weekly

Your weekly dose of Kotlin

https://proandroiddev.com/
/portal/rest/jcr/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/pad/ProAndroidDev
ProAndroidDev

Android Tech Blogs, Case Studies and Step-by-Step Coding

/detail?content-id=/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/Zalando/Zalando
/portal/rest/jcr/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/Zalando/Zalando
Zalando

Meet one of Berlin's top employers

/detail?content-id=/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/Academy for App Success/Academy for App Success
/portal/rest/jcr/repository/collaboration/Groups/spaces/droidcon_hq/Documents/public/employerbranding/Academy for App Success/Academy for App Success
Academy for App Success

Google Play resources tailored for the global droidcon community

Follow us

Team droidcon

Get in touch with us

Write us an Email

 

 

Quicklinks

> Code of Conduct

> Terms and Conditions

> How to hold a conference

> FAQs

> Imprint

Droidcon is a registered trademark of Mobile Seasons GmbH Copyright © 2020. All rights reserved.

powered by Breakpoint One