- Hands-On Design Patterns with Kotlin
- Alexey Soshin
- 179字
- 2021-06-25 20:49:29
Composing an email
As a software architect, one of my main channels of communication is email. Probably this is true of most software development roles.
An email has the following:
- An address (at least one is mandatory)
- CC (zero or more, optional)
- Title (optional)
- Body (optional)
- Attachment (zero or more, optional)
Let's assume I'm really lazy, and would like to schedule emails to be sent while I'm actually biking around the neighborhood.
The actual scheduling logic will be postponed to Chapter 8, Threads and Coroutines, and Chapter 9, Designed for Concurrency, which discuss scheduling and concurrency. For now, let's see what our Mail class may look like:
data class Mail(val to: String,
val cc: List<String>,
val bcc: List<String>,
val title: String?,
val message: String)
So, we've already seen data class in action in the previous chapters. We've also discussed nullable and non-nullable types, such as String? versus String.
Now is a good time to discuss how collections work in Kotlin, since this is the first time we have a class that deals with them directly.
- TypeScript Essentials
- Getting Started with React
- 在最好的年紀(jì)學(xué)Python:小學(xué)生趣味編程
- Learn Scala Programming
- 老“碼”識(shí)途
- Visual C
- R大數(shù)據(jù)分析實(shí)用指南
- 微信小程序項(xiàng)目開發(fā)實(shí)戰(zhàn)
- 基于Struts、Hibernate、Spring架構(gòu)的Web應(yīng)用開發(fā)
- Node Cookbook(Second Edition)
- 零基礎(chǔ)輕松學(xué)C++:青少年趣味編程(全彩版)
- Mastering Gephi Network Visualization
- Python預(yù)測(cè)之美:數(shù)據(jù)分析與算法實(shí)戰(zhàn)(雙色)
- 大規(guī)模語言模型開發(fā)基礎(chǔ)與實(shí)踐
- PHP動(dòng)態(tài)網(wǎng)站開發(fā)實(shí)踐教程