Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Kotlin - Padrões e Boas Práticas
Search
Rafael Toledo
November 18, 2017
Programming
730
1
Share
Kotlin - Padrões e Boas Práticas
Apresentada no DevFest Belo Horizonte 2017
Rafael Toledo
November 18, 2017
More Decks by Rafael Toledo
See All by Rafael Toledo
Gamedev com Kotlin Native
rafaeltoledo
0
110
Kotlin Multiplataforma: Compartilhando código entre Android e iOS
rafaeltoledo
0
300
Motion Layout
rafaeltoledo
1
170
Pipeline Android
rafaeltoledo
3
190
Android Architecture Components
rafaeltoledo
7
190
What's New in Kotlin 1.3
rafaeltoledo
0
170
An Overview of Multiplatform Kotlin
rafaeltoledo
2
160
Compartilhando Código com Kotlin Multiplataforma
rafaeltoledo
2
290
Android Assíncrono
rafaeltoledo
3
240
Other Decks in Programming
See All in Programming
ハーネスエンジニアリングにどう向き合うか 〜ルールファイルを超えて開発プロセスを設計する〜 / How to approach harness engineering
rkaga
24
14k
JOAI2026 1st solution - heron0519 -
heron0519
0
140
GitHubCopilotCLIをはじめよう.pdf
htkym
0
240
ハーネスエンジニアリングとは?
kinopeee
12
6k
Offline should be the norm: building local-first apps with CRDTs & Kotlin Multiplatform
renaudmathieu
0
220
〜バイブコーディングを超えて〜 チームで実験し続けたAI駆動開発
tigertora7571
0
150
属人化しないコード品質の作り方_2026.04.07.pdf
muraaano
0
230
CursorとClaudeCodeとCodexとOpenCodeを実際に比較してみた
terisuke
1
490
AIを導入する前にやるべきこと
negima
2
150
Going Multiplatform with Your Android App (Android Makers 2026)
zsmb
2
450
ルールルルルルRubyの中身の予備知識 ── RubyKaigiの前に予習しなイカ?
ydah
1
210
「Linuxサーバー構築標準教科書」を読んでみた #ツナギメオフライン.7
akase244
0
1.4k
Featured
See All Featured
Prompt Engineering for Job Search
mfonobong
0
270
How to Ace a Technical Interview
jacobian
281
24k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.2k
Keith and Marios Guide to Fast Websites
keithpitt
413
23k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.4k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
A Soul's Torment
seathinner
6
2.7k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.7k
Visual Storytelling: How to be a Superhuman Communicator
reverentgeek
2
510
Un-Boring Meetings
codingconduct
0
270
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
280
How to build a perfect <img>
jonoalderson
1
5.4k
Transcript
None
None
None
None
None
None
None
None
None
User user = new User(); user.setName("Rafael Toledo"); // Obrigatório user.setEmail("
[email protected]
");
// Obrigatório user.setPhone("+55 11 99999-9999"); // Opcional
User user = new User.Builder("Rafael Toledo", "
[email protected]
") .phone("+55 11 99999-9999")
.build();
class User(val name: String, val email: String, val phone: String?
= null) User(name = "Rafael Toledo", email = "
[email protected]
")
class User(val name: String, val email: String, val phone: String?
= null) User(name = "Rafael Toledo", email = "
[email protected]
", phone = "+55 11 99999-9999")
taxCalculator { country = Tax.COUNTRY_BRAZIL period { from = date("2017-01-01")
to = date("2017-10-31") } type = Tax.TYPE_IRPF payment { type = Tax.PAYMENT_BANK_TRANSFER bank { agency = "1234" account = "012345-9" ...
None
fun ViewGroup.inflate(layoutRes: Int, attachToRoot: Boolean = false): View { return
LayoutInflater.from(context).inflate(layoutRes, this, attachToRoot) }
None
None
None
None
None
validateAddress(addressFrom(jsonNode)) validateAddress(jsonNode.toAddress()) private fun JsonNode.toAddress() = Address( getRequired("street").asText(), getRequired("town").asText(), get("postcode")?.asPostCode(),
getRequired("country").asCountryCode())
validateAddress(addressFrom(jsonNode)) validateAddress(jsonNode.toAddress()) private fun JsonNode.toAddress() = Address( getRequired("street").asText(), getRequired("town").asText(), get("postcode")?.asPostCode(),
getRequired("country").asCountryCode())
// Antes enableCheckbox(isFreeDelivery(addressFrom(jsonNode))) // Depois enableCheckbox(jsonNode.toAddress().isFreeDelivery())
// Antes if (userCanEditSubmission(currentUser, submission)) { ... } // After
if (currentUser.canEdit(submission)) { ... }
None
None
None
None
None
None
None
None
None
None
if (savedInstanceState != null) { ... } savedInstanceState?.let { ...
}
None
None
// Confuso if (value?.isTrue ?: false) { ... } //
Parece redundante, mas é mais claro! if (value?.isTrue == true) { ... }
None
None
None
None
None
None
None
None
None
None
None
None
None
None
@Deprecated("Use X instead") @Throws(ExceptionInInitializerError::class) fun relevantMethod() { ... }
None
// Em vez de apply plugin: "kotlin-android" apply plugin: "kotlin-android-extensions"
// Por que não... apply plugin: "org.jetbrains.kotlin.android" apply plugin: "org.jetbrains.kotlin.android.extensions" apply plugin: "org.jetbrains.kotlin.kapt"
None
None
None