DEV Community

Cover image for As a Junior Android Dev — Should I Memorize All This, or Just Ask AI?
Aalaa Fahiem
Aalaa Fahiem

Posted on

As a Junior Android Dev — Should I Memorize All This, or Just Ask AI?

I was learning Retrofit and staring at a wall of boilerplate code thinking:
"Am I supposed to have all of this memorized?"

So I asked — and the honest answer surprised me. Most juniors are afraid to raise this question. Here's what I found out.


Should You Write It All From Memory?

No. And yes. It depends on what part.

Think of it like learning to drive:

  • You don't need to know how to build a car engine from scratch
  • But you do need to know how to drive, and what to do when something breaks

There are 3 zones — and once you understand them, the whole learning process feels way less overwhelming.


Zone 1 — Let AI Write It

Boilerplate. Nobody memorizes this.

// This setup in AppModule.kt? AI writes it. Every time.
val okHttpClient = OkHttpClient.Builder()
    .connectionSpecs(listOf(spec, ConnectionSpec.CLEARTEXT))
    .protocols(listOf(Protocol.HTTP_1_1))
    .dns(object : Dns {
        override fun lookup(hostname: String): List<InetAddress> {
            return Dns.SYSTEM.lookup(hostname).filter { it is Inet4Address }
                .ifEmpty { Dns.SYSTEM.lookup(hostname) }
        }
    })
    .connectTimeout(30, TimeUnit.SECONDS)
    ...
Enter fullscreen mode Exit fullscreen mode

Nobody writes this from memory. Senior devs copy-paste it from their last project. Use AI or docs — zero shame.


Zone 2 — You MUST Know This Cold

This will be tested in interviews. Learn it by heart.

1. Writing the API interface yourself

interface PokeApi {
    @GET("pokemon")
    suspend fun getPokemonList(
        @Query("limit") limit: Int,
        @Query("offset") offset: Int,
    ): PokemonList

    @GET("pokemon/{name}")
    suspend fun getPokemonInfo(@Path("name") name: String): Pokemon
}
Enter fullscreen mode Exit fullscreen mode

It's only ~10 lines, and it's the heart of Retrofit. Write it without help.

2. The basic Retrofit builder

Retrofit.Builder()
    .baseUrl("https://pokeapi.co/api/v2/")
    .addConverterFactory(GsonConverterFactory.create())
    .build()
    .create(PokeApi::class.java)
Enter fullscreen mode Exit fullscreen mode

4 lines. Know these by heart.

3. The data flow in your head

Be able to explain this out loud without hesitation:

UI → ViewModel → Repository → API interface → Retrofit builds URL → OkHttp sends it → Gson parses response → back up the chain
Enter fullscreen mode Exit fullscreen mode

4. What the annotations do

  • @GET — Sends a GET request to the given endpoint
  • @POST — Sends a POST request
  • @Query — Adds ?key=value to the end of the URL
  • @Path — Fills a {slot} inside the URL
  • @Body — Sends an object as the request body (JSON)

5. Why suspend?

"Network calls block the thread. suspend runs them in a coroutine so the UI doesn't freeze."

Key points to remember:

  • suspend means the function can pause while waiting (for network, DB, etc.) and resume later without blocking the app
  • It does not create a new thread — it just allows pausing and resuming
  • You call it from a coroutine scope like viewModelScope.launch { }
  • Retrofit API calls are suspend because network requests take time

Zone 3 — Understand It, Don't Memorize It

// Resource wrapper — understand WHY it exists
sealed class Resource<T> {
    class Success<T>(data: T)
    class Error<T>(message: String)
    class Loading<T>()
}
Enter fullscreen mode Exit fullscreen mode

You should be able to explain:

"It wraps the result so the ViewModel can handle success, error, and loading states cleanly."

You don't need to write it from memory — but if an interviewer shows it to you, you need to explain it confidently.

The mental model:

suspend              → gets data safely from slow operations
Resource             → tells the app what happened with the data
ViewModel + StateFlow → sends the new state to the UI
Enter fullscreen mode Exit fullscreen mode

The Real Interview Questions

🟢 Easy — Answer instantly

"What is Retrofit?"
A type-safe HTTP client that turns your interface methods into network calls.

"What is @GET?"
Annotation that makes the function send a GET request to that endpoint.

"Difference between @Query and @Path?"
@Path fills a {slot} in the URL, @Query adds ?key=value at the end.

"What is Gson converter?"
Converts JSON from the server into Kotlin/Java objects automatically.

"Why suspend?"
Network calls are slow — suspend runs them off the main thread so the UI doesn't freeze.


🟡 Medium — Think 5 seconds, then answer

"What is OkHttp and how does it relate to Retrofit?"

Retrofit sits on top of OkHttp. Retrofit handles the interface, annotations, and conversion. OkHttp is the actual engine that opens the socket and sends/receives bytes. You can customize OkHttp (timeouts, interceptors, headers) and plug it into Retrofit.


"What is an Interceptor?"

A piece of code that runs on every request before it's sent (or every response before it arrives). Used for adding auth headers, logging, modifying requests.


"What is the Repository pattern and why use it?"

A middle layer between the ViewModel and the data source (API/database). The ViewModel doesn't care whether data comes from the internet or a local DB — it just asks the Repository. Makes testing easier and keeps code clean.


"What does @SerializedName do?"

Tells Gson to map a specific JSON key to a Kotlin field, even if the names are different. Example: JSON has "base_experience" but Kotlin uses baseExperience.


🔴 Hard — Bonus points if you nail these

"What happens if you don't add suspend to a Retrofit function?"

Before Retrofit 2.6, you used Call<T>. With suspend, Retrofit uses coroutines natively and runs on a background thread automatically. Without suspend in a coroutine-based project, you'd get a crash or have to handle Call<T> manually.


"How would you add an auth token to every request?"

Add an OkHttp Interceptor:

.addInterceptor { chain ->
    val request = chain.request().newBuilder()
        .header("Authorization", "Bearer $token")
        .build()
    chain.proceed(request)
}
Enter fullscreen mode Exit fullscreen mode

"What is @Singleton in Hilt and why does Retrofit need it?"

Creating a Retrofit instance is expensive — it sets up connection pools, parsers, and configuration. @Singleton tells Hilt to create it once and reuse the same instance everywhere.

Key points:

  • Without @Singleton, Hilt may create multiple Retrofit objects — wasteful and slow
  • In Android apps, we keep one Retrofit instance for the whole app and inject it wherever needed

TL;DR

  • Zone 1 — Boilerplate → Let AI write it. Always.
  • Zone 2 — Core concepts → Memorize it. Interviews will ask.
  • Zone 3 — Patterns → Understand the why, not the exact syntax.

The goal isn't to be a human compiler. It's to understand the system well enough to drive it, debug it, and explain it — even when you don't know every line by heart.


Still learning Kotlin and Android as a junior dev — writing about it as I go. If this helped, I'd love to hear what you're building! 👇

Top comments (0)