0Pricing
Kotlin Multiplatform Academy · Aula

Projete uma API pública pequena

Decida o que expor e o que manter interno

Projete uma API pública pequena é uma aula grátis de Kotlin Multiplatform Academy no CoddyKit. Esta é a aula 1 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Kotlin Multiplatform Academy, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Kotlin Multiplatform Academy inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

What a Public API Is

Your module's public API is the set of functions and types other code is allowed to call. It is the front door both apps walk through.

Small Surface Wins

A small surface area means fewer things to learn and fewer things to break. Expose only what callers truly need, nothing more. 🎯

Start From the Use Case

Design backwards: write the call site you wish you had first. Let that ideal usage shape what your public functions look like.

// Imagine this is how both apps will call you
val text = greeter.greet("Maya")

Expose Intent, Hide Steps

A good API shows the intent and hides the steps. Callers say what they want, not how the work gets done inside.

Name Things Clearly

Clear names are half your API. A method called priceWithTax tells the whole story without any extra docs to read.

fun priceWithTax(base: Double, rate: Double): Double {
    return base + base * rate
}

Prefer Simple Inputs

Take plain, obvious inputs like strings and numbers. Simple parameters make your API easy to call from both Android and iOS.

Return Useful Types

Return shared data classes instead of loose values. A typed result is self-describing and far harder to misuse.

data class Quote(val total: Double, val currency: String)

Hide the Helpers

Internal helpers and rough edges should stay private. Only the entry points a caller actually uses belong in the public API.

Easy to Add, Hard to Remove

Every public thing is a promise. It is easy to add new API later, but removing it can break callers, so expose less up front.

Stay Platform-Neutral

Keep the API platform-neutral. If a signature mentions Android or iOS types, it cannot serve both apps from shared code.

Design for the Reader

The best APIs read like a sentence at the call site. Optimize for the caller, not for whoever wrote the implementation.

Quick Check

Let's test your API design instincts.

Recap

A great public API is small, clearly named, and shaped by real use cases. Expose intent, hide steps, and both teams will love it. 🎉

Perguntas Frequentes

A aula “Projete uma API pública pequena” é grátis?

Sim — o texto completo de “Projete uma API pública pequena” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Kotlin Multiplatform Academy, atualize para CoddyKit PRO. O curso de Kotlin Multiplatform Academy inclui 4 aulas no total.

O que vou aprender em “Projete uma API pública pequena”?

Decida o que expor e o que manter interno Você pratica Kotlin Multiplatform Academy com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar Kotlin Multiplatform Academy?

Nenhuma experiência prévia é necessária. Kotlin Multiplatform Academy no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 1 de 4.

Quanto tempo leva a aula “Projete uma API pública pequena”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de Kotlin Multiplatform Academy?

Sim. Cada aula de Kotlin Multiplatform Academy inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. Projete uma API pública pequena
  2. Visibilidade internal versus pública
  3. Organize pacotes dentro do módulo
  4. Documente a API para as duas equipes
← Voltar para Kotlin Multiplatform Academy