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
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
95
Kotlin Multiplataforma: Compartilhando código entre Android e iOS
rafaeltoledo
0
300
Motion Layout
rafaeltoledo
1
150
Pipeline Android
rafaeltoledo
3
180
Android Architecture Components
rafaeltoledo
7
180
What's New in Kotlin 1.3
rafaeltoledo
0
160
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
DevFest Android in Korea 2025 - 개발자 커뮤니티를 통해 얻는 가치
wisemuji
0
180
AI 駆動開発ライフサイクル(AI-DLC):ソフトウェアエンジニアリングの再構築 / AI-DLC Introduction
kanamasa
11
4.8k
これならできる!個人開発のすゝめ
tinykitten
PRO
0
140
組み合わせ爆発にのまれない - 責務分割 x テスト
halhorn
1
180
Navigation 3: 적응형 UI를 위한 앱 탐색
fornewid
1
510
0→1 フロントエンド開発 Tips🚀 #レバテックMeetup
bengo4com
0
450
実はマルチモーダルだった。ブラウザの組み込みAI🧠でWebの未来を感じてみよう #jsfes #gemini
n0bisuke2
3
1.4k
CSC307 Lecture 02
javiergs
PRO
1
740
令和最新版Android Studioで化石デバイス向けアプリを作る
arkw
0
470
React 19でつくる「気持ちいいUI」- 楽観的UIのすすめ
himorishige
11
2.7k
チームをチームにするEM
hitode909
0
430
Flutter On-device AI로 완성하는 오프라인 앱, 박제창 @DevFest INCHEON 2025
itsmedreamwalker
1
180
Featured
See All Featured
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
0
84
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
2.8k
The Pragmatic Product Professional
lauravandoore
37
7.1k
The Language of Interfaces
destraynor
162
26k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
61
51k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
180
Into the Great Unknown - MozCon
thekraken
40
2.2k
How to build a perfect <img>
jonoalderson
1
4.8k
SEO for Brand Visibility & Recognition
aleyda
0
4.1k
JAMstack: Web Apps at Ludicrous Speed - All Things Open 2022
reverentgeek
1
300
For a Future-Friendly Web
brad_frost
180
10k
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