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
Compose CameraX on Android
Compose CameraX on Android

By Peng Jiang

Android new UI toolkit Jetpack compose is in beta now, which has all the features you need to build production-ready apps. CameraX is another Jetpack support library, which let you control the camera easier. As compose is still under development, lots of the views are still not available the compose way.

By ProAndroidDev -
Android News
Getting… your BottomSheetScaffold working on Jetpack Compose Beta 03
Getting… your BottomSheetScaffold working on Jetpack Compose Beta 03

By Carlos Mota

It’s Monday, no releases this week, and… there’s a new version of Jetpack Compose — beta 03—available. What a perfect time to just increment 02 to 03 and see what’s new. The API is (almost) final so after updating from alpha to beta there weren’t any big changes to do. However, and remember that’s still in development, there’s always something that I need to update. 

By ProAndroidDev -
Android News
Noisy Code With Kotlin Scopes
Noisy Code With Kotlin Scopes

By Chetan Gupta

Scopes make your code more readable? think again... You are going to encounter these scope functions namely let, run, apply, also, within every Kotlin codebase, along with all the mischievous ways developers exploit their usage from the way they were intended for. Let see how popular opinion on those ends up just as a code noise.

By ProAndroidDev -
Android News
Improving Android DataBinding with Bindables library
Improving Android DataBinding with Bindables library

By Jaewoong Eum

DataBinding is one of the most important factors for MVVM architecture. The basic concept of DataBinding is to link the view and view model via observer patterns, properties, event callbacks, etc. Linking and automating communication between the view via the bound properties or something in the view model has a lot of benefits in the MVVM architecture concept.

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