avatarAvik Sharma Chowdhury

Summary

The website content outlines the considerations and processes for designing efficient Android applications, emphasizing both high-level and low-level system design, with a focus on scalability, user experience, and technical choices such as architecture patterns and API endpoints.

Abstract

Designing an Android application that is both efficient and scalable is a complex task that requires careful planning and consideration of various factors. The content discusses the importance of understanding interviewer expectations during system design interviews, which typically focus on high-level design but may delve into low-level specifics. Key points include asking clarifying questions to determine requirements and constraints, selecting appropriate architecture patterns, and considering failure cases and edge scenarios. The article also touches on the technical aspects of Android development, such as data storage, background processing, and the use of APIs, with examples provided for API endpoint design. Additionally, the content advises developers to be prepared for coding exercises that involve writing service classes, view-models, repositories, and views, and to be familiar with tools and libraries like Coroutines, RX Java, Retrofit, and Firebase.

Opinions

  • The author stresses the importance of scalability, suggesting that while any developer can create an app, supporting millions of users requires special considerations.
  • There is an emphasis on the need to ask many questions during an interview to fully understand the system requirements and to identify potential edge cases.
  • The choice of architecture pattern should be justified, as interviewers may challenge the developer's reasoning for selecting a particular pattern.
  • The author suggests that handling failures and edge cases is crucial when discussing feature implementation, advocating for robust error handling and recovery strategies.
  • There is a recommendation to follow the official Android Developer documentation to understand the basics of Android development thoroughly.
  • The author encourages developers to familiarize themselves with various aspects of the Android ecosystem, including memory and battery optimization, the Android build process, and third-party services like Google Play and ads SDK.
  • The article concludes with a personal touch, inviting readers to support the author's content creation efforts by buying them a coffee.

System Design of Android Application

Designing an efficient mobile app architecture is an arduous task. As an android app developer, you need to keep in mind a lot of things such as supporting multiple devices and OS versions, using memory efficiently, etc. So I would say it’s not an easy task to design an efficient mobile app. Anyone can develop an application, however, if we want to support millions of users we need to keep in mind a few things so that our app runs smoothly on some devices but lags or crashes on other devices. Here I will basically share my interview experience to design efficient android apps.

Let’s first talk about my interview experience to design an android app. I will discuss both high-level system design and low-level system design.

High-Level Design

In a system design interview, you can expect high-level system design in almost 90% of cases. However, some company prefers low-level design which involves coding specific modules in the system.

The first and foremost thing in a system design interview is to understand what kind of system the interviewer is expecting you to design. You need to understand the requirements well. So ask as many questions as possible. Try to find edge cases. Write down the requirements briefly. For example, if the interviewer asks you to design a photo-sharing app like Instagram, you can ask the following questions:

  1. How many users should we support? (An app developer does not need to be concerned about this. However, it’s good to ask this question because this will indicate you actually care about scalability.)
  2. What is the lowest OS version we are gonna support?
  3. How many photos a user can upload? Is there any limit? Can we assume that a user can upload at most 10 photos?
  4. We need to generate a feed for a particular user, right? So that means a user can follow other users. The feed for a particular user is generated by the photos uploaded by the users whom that user follows. Is there any limit on how many users a particular user can follow?
  5. About the accounts, I think we need to differentiate between a normal user and a celebrity user. Do I need to keep this in mind while designing my system or for now I will just focus on normal users?
  6. Do we support short video clips like 5/10 secs or focus only on uploading photos?
  7. A user can like other users’ photos. Do we support commenting like Instagram?
  8. Will there be any follow-suggestions section?

N.B: you can also ask about direct messaging and story like features. However, interviewer might ask you to focus on only photo sharing; which is basically uploading photos and generating feeds.

After gathering the requirements, you can jump to designing specific modules. You can talk about which architecture pattern you are going to use. However, be ready to defend why you chose the pattern. The interviewer might ask you why you think this pattern is best suited to this application.

Then you need to discuss what your components would look like. For example, you can start with uploading photos. How a photo upload would work? Do you want to upload it instantly or run a background worker to upload the photo? The photo might need to be compressed. Do you want a filtering option? After uploading a photo successfully you can show a notification to the user that the photo has been uploaded successfully. In case of failure, you can prompt the user to try again or check network connectivity. Always talk about failures or edge cases while talking about a particular feature. The failed photos can be stored in the local DB temporarily and can be uploaded when network connectivity is available. This can be easily done using WorkManager.

If you want to store something in a local DB, then talk about how you want to store it. Talk about relevant entities and fields you want to store. You might need to define the name of the entities and the fields in each entity.

You might also need to define some API endpoints. For example, to upload a photo you might define an API like this:

@POST(“api/uploadphoto/{user_id}”) suspend fun uploadPhoto(@Path(“user_id”) userId: Int, @Body photo : Photo): Boolean

So the above API method an userID and a photo object as parameters and it returns a boolean whether the upload is successful or not.

For a particular architecture pattern in android, you can discuss the components of that pattern. For example, if you go for the MVVM pattern you can discuss the relevant views, models and viewmodels, how data is transferred to view and how to show the data in view etc.

Low-Level Design

Sometimes the interviewer focuses on low-level design. That means you need to write codes for specific modules. In one interview I was asked to write codes for API service class(API endpoints), view-models, repositories and views. So it’s advisable to brush up on your knowledge to tackle this type of interview. Be prepared beforehand whether you want to use coroutine or RX Java with retrofit to do network calls and DB operations.

Follow the Android Developer site to understand the basics. Brush up your knowledge on memory, battery optimization, architecture, android build process, background tasks, UI, camera, etc. Moreover, it’s good to know about firebase, Google Play, ads SDK, etc.

Good luck with your Android system design interview preparation.

Buy me a coffee

If you like this article and want to support me in my content writing, you can buy me a coffee here.

System Design Interview
Android
Android App Development
Mobile App Design
Android App Design
Recommended from ReadMedium