$30 off During Our Annual Pro Sale. View Details »
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
1
720
Kotlin - Padrões e Boas Práticas
Apresentada no DevFest Belo Horizonte 2017
Rafael Toledo
November 18, 2017
Tweet
Share
More Decks by Rafael Toledo
See All by Rafael Toledo
Gamedev com Kotlin Native
rafaeltoledo
0
94
Kotlin Multiplataforma: Compartilhando código entre Android e iOS
rafaeltoledo
0
300
Motion Layout
rafaeltoledo
1
150
Pipeline Android
rafaeltoledo
3
170
Android Architecture Components
rafaeltoledo
7
170
What's New in Kotlin 1.3
rafaeltoledo
0
150
An Overview of Multiplatform Kotlin
rafaeltoledo
2
140
Compartilhando Código com Kotlin Multiplataforma
rafaeltoledo
2
270
Android Assíncrono
rafaeltoledo
3
230
Other Decks in Programming
See All in Programming
안드로이드 9년차 개발자, 프론트엔드 주니어로 커리어 리셋하기
maryang
1
140
ゆくKotlin くるRust
exoego
1
160
Navigation 3: 적응형 UI를 위한 앱 탐색
fornewid
1
460
[AtCoder Conference 2025] LLMを使った業務AHCの上⼿な解き⽅
terryu16
6
770
AI Agent Dojo #4: watsonx Orchestrate ADK体験
oniak3ibm
PRO
0
110
Java 25, Nuevas características
czelabueno
0
110
Navigating Dependency Injection with Metro
l2hyunwoo
1
190
チームをチームにするEM
hitode909
0
390
リリース時」テストから「デイリー実行」へ!開発マネージャが取り組んだ、レガシー自動テストのモダン化戦略
goataka
0
140
Flutter On-device AI로 완성하는 오프라인 앱, 박제창 @DevFest INCHEON 2025
itsmedreamwalker
1
150
Patterns of Patterns
denyspoltorak
0
350
新卒エンジニアのプルリクエスト with AI駆動
fukunaga2025
0
230
Featured
See All Featured
Introduction to Domain-Driven Design and Collaborative software design
baasie
1
520
Bash Introduction
62gerente
615
210k
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.1k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
1
29
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
0
65
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.2k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.6k
Stewardship and Sustainability of Urban and Community Forests
pwiseman
0
73
Building AI with AI
inesmontani
PRO
1
570
Connecting the Dots Between Site Speed, User Experience & Your Business [WebExpo 2025]
tammyeverts
10
750
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Bootstrapping a Software Product
garrettdimon
PRO
307
120k
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