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
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
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
150
Compartilhando Código com Kotlin Multiplataforma
rafaeltoledo
2
290
Android Assíncrono
rafaeltoledo
3
240
Other Decks in Programming
See All in Programming
How Swift's Type System Guides AI Agents
koher
0
270
クラウドネイティブなエンジニアに向ける Raycastの魅力と実際の活用事例
nealle
2
200
The Monolith Strikes Back: Why AI Agents ❤️ Rails Monoliths
serradura
0
340
ドメインイベントでビジネスロジックを解きほぐす #phpcon_odawara
kajitack
3
780
ハーネスエンジニアリングにどう向き合うか 〜ルールファイルを超えて開発プロセスを設計する〜 / How to approach harness engineering
rkaga
23
13k
おれのAgentic Coding 2026/03
tsukasagr
1
150
LM Linkで(非力な!)ノートPCでローカルLLM
seosoft
0
500
PDI: Como Alavancar Sua Carreira e Seu Negócio
marcelgsantos
0
120
Programming with a DJ Controller — not vibe coding
m_seki
3
100
AWS re:Invent 2025の少し振り返り + DevOps AgentとBacklogを連携させてみた
satoshi256kbyte
3
160
2026_04_15_量子計算をパズルとして解く
hideakitakechi
0
110
SkillがSkillを生む:QA観点出しを自動化した
sontixyou
6
3.4k
Featured
See All Featured
Making the Leap to Tech Lead
cromwellryan
135
9.8k
Building an army of robots
kneath
306
46k
Test your architecture with Archunit
thirion
1
2.2k
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
320
DevOps and Value Stream Thinking: Enabling flow, efficiency and business value
helenjbeal
1
170
ラッコキーワード サービス紹介資料
rakko
1
3.1M
Skip the Path - Find Your Career Trail
mkilby
1
110
The Straight Up "How To Draw Better" Workshop
denniskardys
239
140k
Practical Tips for Bootstrapping Information Extraction Pipelines
honnibal
25
1.9k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.6k
brightonSEO & MeasureFest 2025 - Christian Goodrich - Winning strategies for Black Friday CRO & PPC
cargoodrich
3
680
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.7k
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